<template>
  <div id="create-plan">
    <div class="plan-card">
      <div class="plan-card-header">
        <div class="title">商品信息设置</div>
      </div>
      <div class="plan-card-content other-style">
        <div>
          <el-form
              ref="planForm"
              :model="planForm"
              :rules="goodsRules"
              label-width="120px"
              class="goods-form"
          >
            <el-form-item label="计划名称 :" prop="planName">
              <el-input
                  placeholder="请输入计划名称"
                  size="small"
                  v-model="planForm.planName"
                  class="form-input"
                  clearable
              ></el-input>
            </el-form-item>
            <el-form-item label="店铺名称 :" prop="shopId">
              <el-select
                  disabled="isForbidModify"
                  v-model="planForm.shopId"
                  class="form-input"
                  placeholder="请选择店铺名称"
                  size="small"
                  filterable
                  :filter-method="dataFilter"
                  clearable
              >
                <el-option
                    v-for="(stores, index) in shopNameList"
                    :key="index"
                    :label="stores.name"
                    :value="stores.id"
                ></el-option>
              </el-select>
              <!-- <el-input v-else  :disabled="isForbidModify" size="small" v-model="planForm.shopName" class="form-input"></el-input> -->
            </el-form-item>
            <el-form-item label="商品链接 :" prop="goodsUrl">
              <el-input
                  placeholder="请输入商品链接"
                  v-model="planForm.goodsUrl"
                  size="small"
                  disabled="isForbidModify"
                  class="form-input"
                  @blur="changeGoodsUrl"
              ></el-input>
            </el-form-item>
            <el-form-item label="商品id :" prop="productId">
              <el-input
                  placeholder
                  v-model="planForm.productId"
                  size="small"
                  :disabled="true"
                  class="form-input"
              ></el-input>
            </el-form-item>
            <el-form-item label="店铺种类 :" prop="shopType">
              <el-select
                  v-model="planForm.shopType"
                  disabled="isForbidRevise"
                  placeholder="请选择店铺种类"
                  size="small"
                  @change="platFormTypeChange"
                  class="form-input"
              >
                <el-option
                    v-for="(stores, index) in platformTypeList"
                    :key="index"
                    :label="stores.label"
                    :value="stores.value"
                ></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="商品标题 :" prop="goodsTitle">
              <el-input v-if='planForm.shopType==4'
                        placeholder="请输入商品标题"
                        v-model="planForm.goodsTitle"
                        size="small"
                        class="form-input"
              ></el-input>
              <el-input v-else
                        placeholder="请输入商品标题"
                        v-model="planForm.goodsTitle"
                        size="small"
                        :disabled="isForbidRevise"
                        class="form-input"
              ></el-input>
            </el-form-item>
            <!-- coName -->
            <el-form-item label="店铺名称 :" prop="shopName">
              <el-input placeholder v-model="planForm.shopName" disabled="isForbidModify" class="form-input" size="small" clearable />
            </el-form-item>
            <el-form-item label="掌柜昵称 :" prop="goodsSeller" v-if="planForm.shopType == 1 || planForm.shopType == 2">
              <el-input
                  placeholder
                  v-model="planForm.goodsSeller"
                  class="form-input"
                  size="small"
                  clearable
              ></el-input>
            </el-form-item>
            <div class="other-info">
              <el-form-item
                  label="搜索展示价格 :"
                  class="set-error-msg"
                  prop="showMoney"
              >
                <el-input
                    type="number"
                    v-model.number="planForm.showMoney"
                    auto-complete="off"
                    size="small"
                    class="other-info-input"
                    :disabled="isForbidModify"
                ></el-input>
              </el-form-item>
              <el-form-item label="付款人数约 :" prop="payPerson">
                <el-input
                    type="number"
                    v-model.number="planForm.payPerson"
                    onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"
                    auto-complete="off"
                    size="small"
                    class="other-info-input"
                    :disabled="isForbidModify"
                ></el-input>
              </el-form-item>
              <el-form-item
                  label="商品归属地 :"
                  prop="goodsAddress"
                  v-if="planForm.shopType == 1 || planForm.shopType == 2"
              >
                <el-input
                    v-model="planForm.goodsAddress"
                    auto-complete="off"
                    size="small"
                    class="other-info-input"
                    :disabled="isForbidModify"
                ></el-input>
              </el-form-item>
            </div>
          </el-form>
        </div>
        <div class="goods-img-box">
          <div class="goods-img" v-if="planForm.goodsImg && isForbidModify">
            <img :src="planForm.goodsImg" alt=""/>
            <p>商品主图</p>
          </div>
          <div class="goods-img" v-else>
            <el-upload
                class="avatar-uploader"
                :action="BASE_API_URL + 'baseapi/wechart/uploadMerchantPushImg'"
                :data="uploadData"
                :show-file-list="false"
                :on-success="handleAvatarSuccess"
                :before-upload="beforeAvatarUpload"
            >
              <img
                  v-if="planForm.goodsImg"
                  :src="planForm.goodsImg"
                  class="avatar"
              />
              <i v-else class="upload-icon el-icon-ali-upload"></i>
            </el-upload>
            <p>商品主图</p>
          </div>
        </div>
      </div>
    </div>
    <div class="plan-card">
      <div class="plan-card-header">
        <div class="title">任务信息设置</div>
      </div>
      <div class="plan-card-content">
        <div
            class="task-card"
            v-for="(task, index) in planForm.planMessage"
            :key="index"
        >
          <div class="task-card-left">
            <div class="form-box">
              <span class="title"
              ><span class="star-text">*</span>入口类型：</span
              >
              <el-select
                  :disabled="isForbidModify"
                  v-model="task.entranceType"
                  placeholder="请选择入口类型"
                  size="small"
                  @change="
                  val => {
                    entranceTypeChange(val, task);
                  }
                "
                  class="form-input"
              >
                <el-option
                    v-for="(item, index) in entranceTypeList"
                    :key="index"
                    :label="item.label"
                    :value="item.value"
                ></el-option>
              </el-select>
            </div>
            <div class="form-box" v-if="task.entranceType == 3">
              <span class="title"
              ><span class="star-text">*</span>二维码：</span
              >
              <img
                  :src="task.keyword"
                  alt=""
                  v-if="task.keyword && !isForbidModify"
              />
              <div
                  class="qrcode-img-box"
                  @click="getCurSelectQrcode(index)"
                  v-else
              >
                <el-upload
                    class="upload-box"
                    :action="
                    BASE_API_URL + 'baseapi/wechart/uploadMerchantPushImg'
                  "
                    :data="uploadQrcodeData"
                    :show-file-list="false"
                    :on-success="qrcodeSuccess"
                    :before-upload="qrcodeBeforeAvatarUpload"
                >
                  <img v-if="task.keyword" :src="task.keyword" class="avatar"/>
                  <i v-else class="upload-icon el-icon-ali-upload"></i>
                </el-upload>
              </div>
            </div>
            <div class="form-box" v-else>
              <span class="title"
              ><span class="star-text">*</span
              >{{ entranceTypeName[task.entranceType] }}：</span
              >
              <el-input
                  type="textarea"
                  @blur="expressionFilter(task)"
                  @input="inputUpdate($event)"
                  autosize
                  :disabled="isForbidModify"
                  placeholder="请输入内容"
                  v-model="task.keyword"
                  class="form-input"
              ></el-input>
            </div>
          </div>
          <div class="task-card-center" v-if="creatPlanType == 'sales'">
            <div class="center-cell">
              <div class="form-box">
                <span class="title"
                ><span class="star-text">*</span>销量任务：</span
                >
                <el-input
                    type="text"
                    size="small"
                    @input="inputUpdate($event)"
                    onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"
                    :disabled="isForbidModify"
                    placeholder="请输入内容"
                    v-model="task.taskNum"
                    class="form-input"
                ></el-input
                >
                单
              </div>
              <div class="form-box">
                <span class="title"
                ><span class="star-text">*</span>每单拍：</span
                >
                <el-input
                    type="text"
                    size="small"
                    @input="inputUpdate($event)"
                    onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"
                    :disabled="isForbidModify"
                    placeholder="请输入内容"
                    v-model="task.buyNum"
                    class="form-input"
                />
                件
              </div>
            </div>
            <div class="center-cell">
              <div class="form-box">
                <span class="title"
                ><span class="star-text">*</span>拍下单价：</span
                >
                <el-input
                    type="number"
                    size="small"
                    @input="inputUpdate($event)"
                    :disabled="isForbidModify"
                    placeholder="请输入价格"
                    v-model.number="task.payMoney"
                    class="form-input"
                ></el-input>
              </div>
              <div class="form-box">
                <span class="title">拍下规格：</span>
                <el-input
                    type="text"
                    size="small"
                    @input="inputUpdate($event)"
                    :disabled="isForbidModify"
                    placeholder="请输入拍下规格"
                    v-model="task.sku"
                    class="form-input"
                ></el-input>
              </div>
            </div>
          </div>
          <div class="task-card-center flow-center" v-else>
            <div
                class="center-row"
                v-for="(item, itemIndex) in taskTypeList"
                :key="itemIndex"
            >
              <div
                  class="flow-form-box"
                  v-for="(cell, cellIndex) in item.list"
                  :key="cellIndex"
              >
                <span class="title">{{ cell.name }}：</span>
                <el-input
                    type="number"
                    size="small"
                    @input="inputUpdate($event)"
                    onKeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"
                    :disabled="isForbidModify"
                    v-model="task.taskType[cell.type]"
                    class="form-input"
                ></el-input>
              </div>
            </div>
          </div>
          <div class="task-card-right" v-if="!isForbidModify">
            <i
                class="cut-task-icon el-icon-ali-cut"
                @click="cutTask(index)"
                v-if="planForm.planMessage.length != 1"
            ></i>
            <i
                class="add-task-icon el-icon-ali-add"
                @click="addTask"
                v-if="index == planForm.planMessage.length - 1"
            ></i>
          </div>
        </div>
      </div>
    </div>
    <div class="plan-card">
      <div class="plan-card-header">
        <div class="title">发布时间设置</div>
        <div class="tips">*开始时间不能大于结束时间！</div>
      </div>
      <div class="plan-card-content">
        <div class="time-type-box">
          <div class="title">设置类型：</div>
          <div class="tabs-nav" :class="isForbidModify ? 'disabled-click' : ''">
            <div
                class="tab"
                :class="planForm.allotType == item.type ? 'active' : ''"
                v-for="(item, index) in tabsList"
                v-if="item.type != 2"
                :key="index"
                @click="changeTimeTab(item.type)"
            >
              {{ item.name }}
            </div>
          </div>
        </div>
        <div class="set-time-box">
          <div class="title">设置时间：</div>
          <div class="time-select-box" v-if="planForm.allotType == 1">
            <el-date-picker
                v-model="setPlanTime.startTime"
                :disabled="isForbidModify"
                :picker-options="pickerOptions1"
                type="datetime"
                placeholder="选择日期时间"
                value-format="timestamp"
                @change="changeDate"
            ></el-date-picker>
            ~
            <el-date-picker
                type="datetime"
                :disabled="isForbidModify"
                placeholder="选择日期时间"
                :picker-options="pickerOptions1"
                value-format="timestamp"
                v-model="setPlanTime.endTime"
                @change="changeDate"
            ></el-date-picker>
            <el-checkbox
                class="check-box"
                :disabled="isForbidModify"
                v-model="planForm.planOver"
                :true-label="1"
                :false-label="2"
            >设置计划终止时间:
            </el-checkbox
            >
            <el-date-picker
                type="datetime"
                :picker-options="pickerOptions1"
                placeholder="选择日期时间"
                value-format="timestamp"
                v-model="planForm.planOver == 2 ? '' : setPlanTime.overTime"
                :disabled="planForm.planOver == 2 ? true : false"
                @change="changeOverTime"
            ></el-date-picker>
          </div>
          <div class="time-select-box" v-else-if="planForm.allotType == 2">
            <el-date-picker
                v-model="setPlanTime.startTime"
                :disabled="isForbidModify"
                type="datetime"
                placeholder="选择日期时间"
                value-format="timestamp"
                @change="changeManualAllocationTime"
                @blur="selectDate"
            ></el-date-picker>
            ~
            <!--             <el-date-picker type="datetime" placeholder="选择日期时间" :picker-options="pickerOptions1" value-format="timestamp" v-model="setPlanTime.endTime" @change="changeManualAllocationEndTime" @blur="selectDate"></el-date-picker>-->
            <el-date-picker
                type="datetime"
                placeholder="选择日期时间"
                value-format="timestamp"
                v-model="setPlanTime.endTime"
                @change="changeManualAllocationEndTime"
                @blur="selectDate"
            ></el-date-picker>
            <el-checkbox
                class="check-box"
                :disabled="isForbidModify"
                v-model="planForm.planOver"
                :true-label="1"
                :false-label="2"
            >设置计划终止时间:
            </el-checkbox
            >
            <el-date-picker
                type="datetime"
                placeholder="选择日期时间"
                value-format="timestamp"
                v-model="planForm.planOver == 2 ? '' : setPlanTime.overTime"
                :disabled="planForm.planOver == 2 ? true : false"
                @change="changeOverTime"
            ></el-date-picker>
          </div>
          <div class="time-select-box" v-else>
            <el-date-picker
                v-model="setPlanTime.startTime"
                :disabled="isForbidModify"
                :picker-options="pickerOptions2"
                type="datetime"
                placeholder="选择日期时间"
                value-format="timestamp"
                @change="changeStartTime"
            ></el-date-picker>
            <el-checkbox
                class="check-box"
                :disabled="isForbidModify"
                v-model="planForm.planOver"
                :true-label="1"
                :false-label="2"
            >设置计划终止时间:
            </el-checkbox
            >
            <el-date-picker
                type="datetime"
                :picker-options="pickerOptions2"
                placeholder="选择日期时间"
                value-format="timestamp"
                v-model="planForm.planOver == 2 ? '' : setPlanTime.overTime"
                :disabled="planForm.planOver == 2 ? true : false"
                @change="changeOverTime"
            ></el-date-picker>
          </div>
        </div>
        <div class="set-number" v-if="planForm.allotType == 2">
          <div class="title">数量设置：</div>
          <el-collapse>
            <div
                class="set-n-row"
                v-for="(item, key, index) in planForm.planTime"
                :key="index"
            >
              <el-collapse-item>
                <template slot="title">
                  <div>
                    <el-tag>{{ getMonthAndDay(parseInt(key)) }}</el-tag>
                  </div>
                </template>
                <div>
                  <div
                      class="plan-time-box"
                      v-for="(subItem, subKey, subIndex) in item"
                      :key="subIndex"
                  >
                    <div class="time">
                      {{ getDateOfHours(parseInt(subKey)) }}:00
                    </div>
                    <el-input-number
                        :disabled="isForbidEditNum"
                        :min="0"
                        v-model="item[subKey]"
                        controls-position="right"
                        @change="changeAllotNum(item, subKey)"
                    ></el-input-number>
                  </div>
                </div>
              </el-collapse-item>
            </div>
          </el-collapse>
          <div class="count-number">
            <span
            >计划中单数:<span>{{ countIntendOrderNum() }}</span
            >&nbsp;,&nbsp;</span
            >
            <span
            >已分配总计:<span>{{ totalAllotNum }}</span></span
            >
          </div>
        </div>
        <div class="remark-box">
          <div class="remark-example-box" v-if="!isForbidModify">
            <div
                class="remark-example"
                @click="clickRemarkText(rm.remark)"
                v-for="(rm, rmIndex) in remarkList"
                :key="rmIndex"
            >
              {{ rm.remark }}
            </div>
          </div>
          <div class="textarea-box">
            <span class="title">*</span>商家要求(150字以内)：
            <el-input
                type="textarea"
                :disabled="isForbidModify"
                placeholder="请输入内容"
                style="width: 500px;"
                v-model="planForm.remark"
                maxlength="150"
            ></el-input>
          </div>
        </div>
      </div>
    </div>
    <div
        class="plan-card"
        v-if="
        creatPlanType == 'sales' && showZqdArr.indexOf(planForm.shopType) >= 0
      "
    >
      <div class="plan-card-header">
        <div class="title">预约增权单设置</div>
        <div class="tips">
          *此选项选择是，则整个计划的任务只有今天之前做过该商品的流量任务的人才能接到。
        </div>
      </div>
      <div class="plan-card-content">
        <div class="zqd-tips" v-if="planForm.zqd == 1">
          如果选择【是】,确保您今天之前已经放过该商品的流量任务，否则任务将不能派单！
        </div>
        <div>
          <span class="title">预约增权单 :</span>
          <el-radio-group class="radio-box" v-model="planForm.zqd">
            <el-radio :disabled="isForbidModify" :label="1">是</el-radio>
            <el-radio :disabled="isForbidModify" :label="2">否</el-radio>
          </el-radio-group>
          <div v-if="planForm.shopType" class="price-text">
            (每单{{ getTagsDefaultPrice("预约增权") }})
          </div>
        </div>
        <div class="zpd-type-data" v-if="planForm.zqd == 1">
          <el-radio-group v-model="planForm.zqdType">
            <el-radio
                v-for="(cell, cellIndex) in zqdTypeData"
                :key="cellIndex"
                :disabled="isForbidModify"
                :label="cell.value"
            >{{ cell.label }}
            </el-radio
            >
          </el-radio-group>
        </div>
      </div>
    </div>
    <div class="page-footer">
      <el-button class="show-pay-info-btn" @click="creatPlan">{{
          planType == "pay" ? "支付计划" : "创建计划"
        }}
      </el-button>
    </div>
    <el-dialog
        title="选择商品"
        :visible.sync="isShowGoodsDialog"
        width="950px"
        class="dialog-style select-goods-modal"
    >
      <div class="select-goods-modal-header">
        <el-form>
          <el-form-item label="店铺类型：">
            <el-select
                v-model="goodsSelect.shopType"
                placeholder="请选择店铺"
                size="small"
            >
              <el-option label="全部" value=""></el-option>
              <el-option
                  v-for="(item, index) in platformTypeList"
                  :key="index"
                  :label="item.label"
                  :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="店铺名称：">
            <el-select
                v-model="goodsSelect.shopId"
                placeholder="请选择店铺"
                size="small"
            >
              <el-option label="全部" value=""></el-option>
              <el-option
                  v-for="(item, index) in shopNameList"
                  :key="index"
                  :label="item.name"
                  :value="item.id"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="商品ID：">
            <el-input
                size="small"
                placeholder="请输入商品ID"
                v-model="goodsSelect.productId"
                clearable
            ></el-input>
          </el-form-item>
          <el-form-item style="width: 100px;">
            <el-button
                class="inquire-btn"
                icon="el-icon-ali-search"
                @click="searchGoodsData"
            >查询
            </el-button
            >
          </el-form-item>
        </el-form>
      </div>
      <div class="select-goods-modal-content">
        <div
            class="goods-img-box"
            v-for="(item, index) in goodsList"
            :key="index"
            :class="curSelectGoodsIndex == item.id ? 'selectStyle' : ''"
            @click="selectGoods(item, item.id)"
        >
          <img class="goods-img" :src="item.goods_img" alt=""/>
          <div class="text">店铺名称:{{ item.shop_name }}</div>
          <div class="text">商品ID:{{ item.product_id }}</div>
        </div>
        <div class="no-data-img" v-if="goodsList.length == 0">
          <img src="../../assets/image/no-data.png" alt=""/>
          <div class="tips">暂无数据</div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancel-btn" @click="isShowGoodsDialog = false"
        >取消
        </el-button
        >
        <el-button class="submit-btn" @click="sumbitSelectGoods(curSelectGoods)"
        >确认
        </el-button
        >
      </div>
    </el-dialog>
    <el-dialog
        title="选择投放区域"
        :visible.sync="isShowAreaDialog"
        width="900px"
        class="area-dialog"
    >
      <template>
        <div class="tips">*默认全部地区投放（不投放地区可以去掉勾选）</div>
        <div class="area-content">
          <div
              class="province-select"
              v-for="(item, index) in provinceOpitons"
              :key="index"
          >
            <div class="left-box">
              <el-checkbox
                  :indeterminate="item.isIndeterminate"
                  v-model="item.checkAll"
                  @change="handleCheckAllChange($event, item)"
              >{{ item.area }}
              </el-checkbox
              >
            </div>
            <div style="display: inline-block;">
              <el-checkbox-group
                  v-model="item.checkedCities"
                  @change="handleCheckedProvinceChange($event, item)"
              >
                <el-checkbox
                    v-for="city in item.province"
                    :label="city"
                    :key="city"
                >{{ city }}
                </el-checkbox
                >
              </el-checkbox-group>
            </div>
          </div>
        </div>
      </template>
      <span slot="footer" class="dialog-footer" style="position: relative; ">
        <div class="save-btn">
          <el-button @click="saveAreaData">保存设置</el-button>
        </div>
      </span>
    </el-dialog>
    <el-dialog
        title="支付计划"
        :visible.sync="isShowPayPlanDialog"
        width="700px"
        class="dialog-style pay-plan-dialog"
    >
      <div class="dialog-content">
        <div class="card">
          <div class="title">任务店铺</div>
          <div class="content">
            {{ planForm.shopName == "" ? "--" : planForm.shopName }}
          </div>
        </div>
        <div class="card">
          <div class="title">搜索价格</div>
          <div class="content">
            {{ planForm.showMoney == "" ? "--" : planForm.showMoney }}
          </div>
        </div>
        <div class="card">
          <div class="title">付款人数</div>
          <div class="content">
            {{
              planForm.payPerson == "" && planForm.payPerson != 0
                  ? "--"
                  : planForm.payPerson
            }}
          </div>
        </div>
        <div
            class="card"
            v-if="planForm.shopType == 1 || planForm.shopType == 2"
        >
          <div class="title">商品所在地</div>
          <div class="content">
            {{ planForm.goodsAddress == "" ? "--" : planForm.goodsAddress }}
          </div>
        </div>
        <div class="card">
          <div class="title">计划时间</div>
          <div class="content">{{ payPlanInfo.planTime }}</div>
        </div>
        <div class="card" v-if="creatPlanType == 'sales'">
          <div class="title">本金(拍下单价*件数*单数)</div>
          <div class="content">{{ payPlanInfo.capital }}</div>
          <span
              style="color: red;margin: 0 20px;"
              v-if="planForm.rebateType == 1"
          >商家返款本金</span
          >
        </div>
        <div class="card">
          <div class="title">佣金(单数*服务佣金)</div>
          <div class="content">{{ payPlanInfo.commission }}</div>
        </div>
        <div class="card" v-if="isShowOtherService">
          <div class="title">其他服务</div>
          <div class="content">
            <div
                v-for="(item, index) in payPlanInfo.otherService"
                :key="index"
                v-if="item.isShow"
            >
              {{ item.name }}：{{ item.price }}
            </div>
          </div>
        </div>
        <div class="card">
          <div class="title">本次合计冻结金额</div>
          <div class="content">{{ payPlanInfo.freezeMoney }}</div>
        </div>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button class="cancel-btn" @click="isShowPayPlanDialog = false"
        >返回修改
        </el-button
        >
        <el-button
            class="submit-btn"
            :disabled="submitLoading"
            :loading="submitLoading"
            @click="payPlan"
        >确认
        </el-button
        >
      </div>
    </el-dialog>
  </div>
</template>

<script>
import {
  apiShopTagInfo,
  apiGetGoodsInfo,
  apiDelGoods,
  apiMerchantGoods,
  apiChangeGoodsImg,
  apiGetRemarkList,
  apiGetServiceFeeList,
  apiMerchantUserStatus,
  apiCreateSalePlan,
  apiCreateFlowPlan,
  apiSaleDetail,
  apiFlowDetail,
  apiIsBindShop
} from "../../request/api.js";
import {mapGetters, mapActions} from "vuex";
import moment from "moment";

export default {
  data() {
    return {
      // activeName: 'tab1',
      creatPlanType: "sales", //计划类型
      isForbidModify: false, //重新支付禁止修改
      isForbidRevise: false, //抓取商品信息成功后禁止修改信息
      planForm: {},
      trafficOrderNum: 0,
      salesPlanForm: {
        token: "",
        shopId: "",
        shopName: "",
        productId: "",
        planName: "",
        payMoney: "",
        goodsUrl: "",
        goodsTitle: "",
        shopType: "",
        goodsSeller: "",
        showMoney: "",
        payPerson: "",
        goodsAddress: "",
        goodsImg: "",
        planMessage: [
          {
            keyword: "",
            payMoney: "",
            sku: "",
            entranceType: 1,
            taskNum: 1,
            buyNum: 1
          }
        ],
        allotType: 1,
        planOver: 2,
        startTime: "",
        endTime: "",
        overTime: "",
        planTime: "",
        remark: "",
        placementArea: "",
        ageId: "99",
        sexId: "99",
        creditId: "99",
        modelId: "99",
        checkContent: "",
        rebateType: "",
        tk: 2,
        zqdType: "0",
        zqd: 2,
        payType: ""
      },
      flowPlanForm: {
        token: "",
        shopId: "",
        shopName: "",
        productId: "",
        planName: "",
        goodsUrl: "",
        goodsTitle: "",
        shopType: "",
        goodsSeller: "",
        showMoney: "",
        payPerson: "",
        goodsAddress: "",
        goodsImg: "",
        planMessage: [
          {
            keyword: "",
            entranceType: 1,
            taskNum: 1, //新增
            taskType: {
              1: 0,
              2: 0,
              3: 0,
              4: 0,
              5: 0,
              6: 0,
              7: 0,
              8: 0
            }
          }
        ],
        allotType: 1,
        planOver: 2,
        startTime: "",
        endTime: "",
        overTime: "",
        planTime: "",
        remark: "",
        placementArea: "",
        ageId: "99",
        sexId: "99",
        creditId: "99",
        modelId: "99",
        payType: "",
        zqdType: "0",
        zqd: 2
      },
      goodsRules: {
        shopId: [{required: true, message: "请选择店铺", trigger: "blur"}],
        productId: [
          {required: true, message: "请输入商品id", trigger: "blur"}
        ],
        planName: [
          {required: true, message: "请输入计划名称", trigger: "blur"}
        ],
        shopType: [
          {required: true, message: "请选择店铺种类", trigger: "blur"}
        ],
        shopName: [
          {required: true, message: "请选择店铺名称", trigger: "blur"}
        ],
        goodsUrl: [
          {required: true, message: "请输入商品链接", trigger: "blur"}
        ],
        goodsTitle: [
          {required: true, message: "请输入商品标题", trigger: "blur"}
        ],
        payPerson: [
          {required: true, message: "请输入付款人数", trigger: "blur"}
        ]
      },
      initShopNameList: [],
      shopNameList: [],
      platformNameObject: {
        20: "抖音"
      },
      tagsList: {},
      shopShowType: "",
      platformTypeList: [],
      initPlatformTypeList: [
        {
          label: "抖音",
          value: 20
        }
      ],
      uploadData: {
        area: "goods"
      },
      uploadQrcodeData: {
        area: "qrCode"
      },
      isWphUrl: false,
      isShowGoodsDialog: false,
      goodsSelect: {
        token: "",
        page: 1,
        pageSize: 100,
        shopId: "",
        shopType: "",
        productId: ""
      },
      goodsList: [],
      curSelectGoodsIndex: "",
      curSelectGoods: {},
      entranceTypeList: [
        {
          label: "关键词",
          value: 1
        },
        {
          label: "抖口令",
          value: 2
        },
        {
          label: "二维码",
          value: 3
        },
        {
          label: "直播",
          value: 4
        }
      ],
      entranceTypeName: {
        1: "关键词",
        2: "抖口令",
        3: "二维码",
        4: "视频链接"
      },
      curQrcodeIndex: 0,
      taskTypeList: [
        {
          list: [
            {
              type: 1,
              name: "浏览"
            },
            {
              type: 2,
              name: "浏览+关注"
            },
            {
              type: 3,
              name: "浏览+加购"
            },
            {
              type: 4,
              name: "浏览+收藏"
            }
          ]
        },
        {
          list: [
            {
              type: 5,
              name: "浏览+加购+关注"
            },
            {
              type: 6,
              name: "浏览+关注+收藏"
            },
            {
              type: 7,
              name: "浏览+加购+收藏"
            },
            {
              type: 8,
              name: "浏览+加购+关注+收藏"
            }
          ]
        }
      ],
      tabsList: [
        {
          type: 1,
          name: "平均分配"
        },
        {
          type: 2,
          name: "手动分配"
        },
        {
          type: 3,
          name: "指定时间"
        }
      ],
      setPlanTime: {
        startTime: "",
        endTime: "",
        overTime: ""
      },
      pickerOptions1: {
        disabledDate(time) {
          let curDate = new Date().getTime();
          let three = 6 * 24 * 3600 * 1000;
          let threeMonths = curDate + three;
          return (
              time.getTime() < Date.now() - 8.64e7 || time.getTime() > threeMonths
          );
        }
      },
      pickerOptions2: {
        disabledDate(time) {
          return time.getTime() < Date.now() - 8.64e7;
        }
      },
      totalAllotNum: 0,
      isForbidEditNum: false,
      intendOrderNum: 0,
      oldOverTime: "",
      remarkList: [],
      showSexArr: [1, 2, 13],
      showCreditArr: [1, 2],
      showCheckContentArr: [1, 2],
      showZqdArr: [1, 2],
      isShowAreaDialog: false,
      tagsDefaultPrice: [],
      serviceFeeList: [],
      ageIdArr: ["99"],
      checkContent: "",
      checkContentStatus: false,
      tkCheckType: 2,
      zqdTypeData: [
        {
          value: "0",
          label: "全部"
        },
        {
          value: "1",
          label: "一天内浏览过"
        },
        {
          value: "2",
          label: "两天内浏览过"
        },
        {
          value: "3",
          label: "三天内浏览过"
        },
        {
          value: "4",
          label: "一周内浏览过"
        }
      ],
      isIndeterminate: false,
      provinceOpitons: [
        {
          area: "华东地区",
          province: ["北京市", "天津市", "河北省", "山西省", "内蒙古自治区"],
          checkedCities: [
            "北京市",
            "天津市",
            "河北省",
            "山西省",
            "内蒙古自治区"
          ],
          isIndeterminate: false,
          checkAll: true
        },
        {
          area: "东北地区",
          province: ["辽宁省", "吉林省", "黑龙江省"],
          checkedCities: ["辽宁省", "吉林省", "黑龙江省"],
          isIndeterminate: false,
          checkAll: true
        },
        {
          area: "华东地区",
          province: [
            "上海市",
            "江苏省",
            "浙江省",
            "安徽省",
            "福建省",
            "山东省"
          ],
          checkedCities: [
            "上海市",
            "江苏省",
            "浙江省",
            "安徽省",
            "福建省",
            "山东省"
          ],
          isIndeterminate: false,
          checkAll: true
        },
        {
          area: "华中地区",
          province: ["江西省", "河南省", "湖北省", "湖南省"],
          checkedCities: ["江西省", "河南省", "湖北省", "湖南省"],
          isIndeterminate: false,
          checkAll: true
        },
        {
          area: "华南地区",
          province: ["广东省", "广西壮族自治区", "海南省"],
          checkedCities: ["广东省", "广西壮族自治区", "海南省"],
          isIndeterminate: false,
          checkAll: true
        },
        {
          area: "西南地区",
          province: ["重庆市", "四川省", "贵州省", "云南省", "西藏自治区"],
          checkedCities: ["重庆市", "四川省", "贵州省", "云南省", "西藏自治区"],
          isIndeterminate: false,
          checkAll: true
        },
        {
          area: "西北地区",
          province: [
            "陕西省",
            "甘肃省",
            "青海省",
            "宁夏回族自治区",
            "新疆维吾尔族自治区"
          ],
          checkedCities: [
            "陕西省",
            "甘肃省",
            "青海省",
            "宁夏回族自治区",
            "新疆维吾尔族自治区"
          ],
          isIndeterminate: false,
          checkAll: true
        }
        // ,{
        //   area: '其他地区',
        //   province: [
        //     '香港特别行政区',
        //     '澳门特别行政区',
        //     '台湾省'
        //   ],
        //   checkedCities: [],
        //   isIndeterminate: false,
        //   checkAll: false
        // },
      ],
      checkAll: false,
      isShowPayPlanDialog: false,
      submitLoading: false,
      payPlanInfo: {
        planTime: "",
        capital: "",
        commission: "",
        otherService: {
          sex: {},
          age: {},
          model: {},
          credit: {},
          zqd: {}
        },
        freezeMoney: 0
      },
      originalShopNameList: [],
      isUploadGoodsImg: false,
      isShowOtherService: false,
      planType: this.$route.query.type,
      planId: this.$route.query.id,
      userToken: window.localStorage.getItem("token"),
      merchantData: JSON.parse(window.localStorage.getItem("merchantConfig"))
    };
  },
  created() {
    this.bindShop();
    if (this.creatPlanType == "sales") {
      if (
          !this.merchantData.shop_show_type ||
          this.merchantData.shop_show_type == null
      ) {
        this.platformTypeList = this.initPlatformTypeList;
      } else {
        let shopShowTypeArr = this.merchantData.shop_show_type.split(",");
        for (var i in this.initPlatformTypeList) {
          if (
              shopShowTypeArr.indexOf(
                  this.initPlatformTypeList[i].value.toString()
              ) >= 0
          ) {
            this.platformTypeList.push(this.initPlatformTypeList[i]);
          }
        }
      }
    } else {
      this.platformTypeList = [
        {
          label: "抖音",
          value: 20
        }
      ];
    }
    this.getShopTagInfo();
    this.goodsSelect.token = this.userToken;
    this.searchGoodsData();
    this.initCurTime();
    this.getRemarkList();
    this.getServiceFeeList();
    if (this.creatPlanType == "sales") {
      this.getMerchantUserStatus();
    }
    this.planForm.token = this.userToken;
    if (this.planId) {
      this.getPlanDetail();
    }
  },
  watch: {
    //监听路由跳转
    $route: {
      handler: function (to, from) {
        if (to.path == "/plan/createSalsePlan") {
          this.creatPlanType = "sales";
          this.entranceTypeName = {
            1: "关键词",
            2: "抖口令",
            3: "二维码",
            4: "视频链接",
            5: "其他"
          };
          this.planForm = this.salesPlanForm;
        } else {
          this.creatPlanType = "flow";
          this.entranceTypeName = {
            1: "关键词",
            2: "抖口令",
            3: "视频链接",
            4: "直播"
          };
          this.planForm = this.flowPlanForm;
        }
      },
      immediate: true
    },
    "setPlanTime.endTime": function (val) {
      if (this.planForm.allotType == 2 && !val) {
        this.setPlanTime.endTime = moment()
            .set("hour", 23)
            .set("minute", 59)
            .toDate()
            .getTime();
        this.changeManualAllocationOverTime();
      }
    },
    "setPlanTime.startTime": function (val) {
      if (this.planForm.allotType == 2 && !val) {
        this.setPlanTime.startTime = moment()
            .set("hour", 0)
            .set("minute", 0)
            .toDate()
            .getTime();
      }
    }
  },
  methods: {
    //===============公共================
    bindShop() {
      this.$isClick(true);
      apiIsBindShop({
        token: this.userToken
      })
          .then(res => {
            this.$isClick(false);
            if (res.code == -1) {
              this.$message.error("你尚未绑定店铺，请先前往绑定");
              setTimeout(() => {
                this.$router.push("/shopManage/shopManage");
              }, 1000);
            }
          })
          .catch(res => {
            this.$isClick(false);
            this.$message.error(res.msg);
          });
    },
    getMerchantUserStatus() {
      this.$isClick(true);
      apiMerchantUserStatus({
        token: this.userToken
      })
          .then(res => {
            this.$isClick(false);
            if (res.code == 1) {
              this.checkContentStatus =
                  res.msg.check_content_status == 2 ? true : false;
              this.planForm.rebateType = res.msg.rebate_type;
              this.tkCheckType = res.msg.tk_check_type;
            }
          })
          .catch(res => {
            this.$isClick(false);
          });
    },
    getServiceFeeList() {
      this.$isClick(true);
      apiGetServiceFeeList({
        token: this.userToken
      })
          .then(res => {
            this.$isClick(false);
            if (res.code == 1) {
              this.serviceFeeList = res.msg;
              this.platFormTypeChange();
            }
          })
          .catch(res => {
            this.$isClick(false);
          });
    },
    getRemarkList() {
      this.$isClick(true);
      apiGetRemarkList()
          .then(res => {
            this.$isClick(false);
            if (res.code == 1) {
              this.remarkList = res.msg;
            }
          })
          .catch(res => {
            this.$isClick(false);
          });
    },
    async getShopTagInfo() {
      this.$isClick(true);
      apiShopTagInfo({
        token: this.userToken
      })
          .then(res => {
            this.$isClick(false);
            if (res.code == 1) {
              // 店铺列表(过滤抖音一拖N)
              this.originalShopNameList = res.msg.shop_list.filter(item => (item.type == 20))
                .map(item => {
                    this.initShopNameList.push({
                      name: this.platformNameObject[item.type] + "-" + item.name,
                      type: item.type,
                      id: item.id
                    });
                    return item
                  })
              this.shopNameList = this.initShopNameList;
              //接单参数
              var arr = res.msg.tag_list;
              var tagNameArr = [
                "age_list",
                "sex_list",
                "model_list",
                "credit_list",
                "address_list"
              ];
              for (var i in arr) {
                for (var j in tagNameArr) {
                  if (i == j) {
                    this.$set(this.tagsList, tagNameArr[j], arr[i]);
                  }
                }
              }
            }
          })
          .catch(res => {
            this.$isClick(false);
          });
    },
    dataFilter(val) {
      this.planForm.shopId = val;
      if (val) {
        this.shopNameList = this.initShopNameList.filter(item => {
          if (
              !!~item.name.indexOf(val) ||
              !!~item.name.toUpperCase().indexOf(val.toUpperCase())
          ) {
            return true;
          }
        });
      } else {
        this.shopNameList = this.initShopNameList;
      }
    },
    // 是否隐藏淘客选项
    isHideTaoKeCard() {
      if (
          this.planForm.goodsUrl.indexOf("item.jd.com") != -1 ||
          this.planForm.goodsUrl.indexOf("item.m.jd.com") != -1 ||
          this.planForm.goodsUrl.indexOf("yangkeduo.com") != -1 ||
          this.planForm.goodsUrl.indexOf("detail.1688.com") != -1 ||
          this.planForm.goodsUrl.indexOf("pinduoduo.com") != -1) {
        // 隐藏淘客选项
        this.tkCheckType = 2
      } else {
        // 展示淘客选项
        this.tkCheckType = 2
      }
    },
    //抓取链接信息
    changeGoodsUrl() {
      if (
          this.planForm.goodsUrl.indexOf("detail.tmall.com") != -1 ||
          this.planForm.goodsUrl.indexOf("item.taobao.com") != -1 ||
          this.planForm.goodsUrl.indexOf("taobao.com") != -1 ||
          this.planForm.goodsUrl.indexOf("item.jd.com") != -1 ||
          this.planForm.goodsUrl.indexOf("item.m.jd.com") != -1 ||
          this.planForm.goodsUrl.indexOf("yangkeduo.com") != -1 ||
          this.planForm.goodsUrl.indexOf("detail.1688.com") != -1 ||
          this.planForm.goodsUrl.indexOf("meeth.tmall.hk") != -1 ||
          this.planForm.goodsUrl.indexOf("detail.tmall.hk") != -1 ||
          this.planForm.goodsUrl.indexOf("pinduoduo.com") != -1
      ) {
        this.isHideTaoKeCard()// 是否隐藏淘客选项
        this.isWphUrl = false;
      } else if (
          this.planForm.goodsUrl.indexOf("m.vip.com") != -1 ||
          this.planForm.goodsUrl.indexOf("detail.vip.com") != -1
      ) {
        this.isWphUrl = true;
        this.planForm.productId = this.planForm.goodsUrl
            .split("detail-")[1]
            .split(".html")[0];
      } else {
        this.isWphUrl = true;
      }
    },
    grabGoodsInfo() {
      this.$loading.show("抓取中");
      if (this.planForm.goodsUrl != "") {
        if (
            this.planForm.goodsUrl.indexOf("detail.tmall.com") != -1 ||
            this.planForm.goodsUrl.indexOf("item.taobao.com") != -1 ||
            this.planForm.goodsUrl.indexOf("item.jd.com") != -1 ||
            this.planForm.goodsUrl.indexOf("item.m.jd.com") != -1 ||
            this.planForm.goodsUrl.indexOf("yangkeduo.com") != -1 ||
            this.planForm.goodsUrl.indexOf("detail.1688.com") != -1 ||
            this.planForm.goodsUrl.indexOf("meeth.tmall.hk") != -1 ||
            this.planForm.goodsUrl.indexOf("detail.tmall.hk") != -1 ||
            this.planForm.goodsUrl.indexOf("pinduoduo.com") != -1
        ) {
          this.isHideTaoKeCard()// 是否隐藏淘客选项
          this.isWphUrl = false;
          this.getProductId();
          apiGetGoodsInfo({
            goodsUrl: escape(this.planForm.goodsUrl),
            token: this.userToken
          })
              .then(res => {
                this.$loading.hide();
                if (res.code == 1) {
                  this.isForbidRevise = true;
                  this.planForm.goodsTitle = res.msg.name;
                  this.planForm.goodsSeller = res.msg.seller_name;
                  this.planForm.shopName = res.msg.shop_name;
                  this.planForm.coName = res.msg.co_name;
                  this.planForm.shopType = res.msg.shop_type;
                  this.platFormTypeChange();
                  this.planForm.goodsImg = res.msg.goods_img;
                  this.planForm.productId = res.msg.product_id;
                  return this.$message.success("抓取商品信息成功");
                } else {
                  this.isForbidRevise = false;
                  this.$message.error(res.msg);
                }
              })
              .catch(res => {
                this.$loading.hide();
                this.$message.error(res.msg);
              });
        } else if (
            this.planForm.goodsUrl.indexOf("m.vip.com") != -1 ||
            this.planForm.goodsUrl.indexOf("detail.vip.com") != -1
        ) {
          this.$loading.hide();
          this.isWphUrl = true;
          this.planForm.goodsTitle = "";
          this.planForm.goodsSeller = "";
          this.planForm.shopName = "";
          this.planForm.shopType = "";
        } else {
          this.$loading.hide();
          return this.$message.error("请输入正确的商品链接再抓取");
        }
      } else {
        this.$loading.hide();
        return this.$message.error("请输入商品链接再抓取");
      }
    },
    getProductId() {
      if (
          this.planForm.goodsUrl.indexOf("item.jd.com") != -1 ||
          this.planForm.goodsUrl.indexOf("item.m.jd.com") != -1
      ) {
        let urlArr = this.planForm.goodsUrl.split(".html")[0];
        let urlArr1 = urlArr.split("/");
        this.planForm.productId = urlArr1[urlArr1.length - 1];
      }
      if (
          this.planForm.goodsUrl.indexOf("detail.tmall.com") != -1 ||
          this.planForm.goodsUrl.indexOf("item.taobao.com") != -1
      ) {
        this.planForm.productId = this.getRequestParam(
            this.planForm.goodsUrl,
            "id"
        );
      }
      if (this.planForm.goodsUrl.indexOf("yangkeduo.com") != -1) {
        this.planForm.productId = this.getRequestParam(
            this.planForm.goodsUrl,
            "goods_id"
        );
      }
      if (this.planForm.goodsUrl.indexOf("detail.1688.com") != -1) {
        let urlArr = this.planForm.goodsUrl.split(".html")[0];
        let urlArr1 = urlArr.split("/");
        this.planForm.productId = urlArr1[urlArr1.length - 1];
      }
      if (this.planForm.goodsUrl.indexOf("pinduoduo.com") != -1) {
        this.planForm.productId = this.getRequestParam(
            this.planForm.goodsUrl,
            "gid"
        );
      }
    },
    getRequestParam(url, name) {
      var reg = new RegExp("(^|&|\\?)" + name + "=([^&]*)(&|$)", "i");
      var r = url.substr(1).match(reg);
      if (r != null) return unescape(r[2]);
      return null;
    },
    //选择商品
    showSelectGoodsDialog() {
      this.curSelectGoods = {};
      this.curSelectGoodsIndex = "";
      this.goodsSelect = {
        token: this.userToken,
        page: 1,
        pageSize: 100,
        shopId: "",
        shopType: "",
        productId: ""
      };
      this.isShowGoodsDialog = true;
    },
    searchGoodsData() {
      this.$isClick(true);
      apiMerchantGoods(this.goodsSelect)
          .then(res => {
            this.$isClick(false);
            if (res.code == 1) {
              this.goodsList = res.msg.res;
            } else {
              this.$message.error(res.msg);
            }
          })
          .catch(res => {
            this.$isClick(false);
            this.$message.error(res.msg);
          });
    },
    selectGoods(item, index) {
      this.curSelectGoods = item;
      this.curSelectGoodsIndex = index;
    },
    sumbitSelectGoods(item) {
      this.isForbidRevise = true;
      this.planForm.goodsTitle = item.goods_title;
      this.planForm.goodsSeller = item.selle_name;
      this.planForm.shopName = item.shop_name;
      this.planForm.shopType = item.shop_type;
      this.planForm.goodsUrl = item.goods_url;
      this.platFormTypeChange();
      this.planForm.goodsImg = item.goods_img;
      this.planForm.productId = item.product_id;
      this.isShowGoodsDialog = false;
      this.isHideTaoKeCard()// 是否隐藏淘客选项
    },
    platFormTypeChange(val) {
      this.setEntranceType();
      //获取接单设置标签对应价格
      if (this.planForm.shopType == 1) {
        for (let i in this.serviceFeeList.service_fee_tb) {
          if (this.serviceFeeList.service_fee_tb[i].pay_type == 2) {
            this.tagsDefaultPrice.push(this.serviceFeeList.service_fee_tb[i]);
          }
        }
      }
      if (this.planForm.shopType == 2) {
        for (let i in this.serviceFeeList.service_fee_tm) {
          if (this.serviceFeeList.service_fee_tm[i].pay_type == 2) {
            this.tagsDefaultPrice.push(this.serviceFeeList.service_fee_tm[i]);
          }
        }
      }
      if (this.planForm.shopType == 3) {
        for (let i in this.serviceFeeList.service_fee_jd) {
          if (this.serviceFeeList.service_fee_jd[i].pay_type == 2) {
            this.tagsDefaultPrice.push(this.serviceFeeList.service_fee_jd[i]);
          }
        }
      }
      if (this.planForm.shopType == 4) {
        for (let i in this.serviceFeeList.service_fee_albb) {
          if (this.serviceFeeList.service_fee_albb[i].pay_type == 2) {
            this.tagsDefaultPrice.push(this.serviceFeeList.service_fee_albb[i]);
          }
        }
      }
      if (this.planForm.shopType == 13) {
        for (let i in this.serviceFeeList.service_fee_wph) {
          if (this.serviceFeeList.service_fee_wph[i].pay_type == 2) {
            this.tagsDefaultPrice.push(this.serviceFeeList.service_fee_wph[i]);
          }
        }
      }
      if (this.planForm.shopType == 15) {
        for (let i in this.serviceFeeList.service_fee_pdd) {
          if (this.serviceFeeList.service_fee_pdd[i].pay_type == 2) {
            this.tagsDefaultPrice.push(this.serviceFeeList.service_fee_pdd[i]);
          }
        }
      }
    },
    setEntranceType() {
      if (this.planForm.shopType == 1 || this.planForm.shopType == 2) {
        if (this.creatPlanType == "sales") {
          this.entranceTypeList = [
            {
              label: "关键词",
              value: 1
            },
            {
              label: "抖口令",
              value: 2
            },
            {
              label: "二维码",
              value: 3
            },
            {
              label: "直播",
              value: 4
            },
            {
              label: "其他",
              value: 5
            }
          ];
        } else {
          this.entranceTypeList = [
            {
              label: "关键词",
              value: 1
            },
            {
              label: "抖口令",
              value: 2
            },
            {
              label: "二维码",
              value: 3
            },
            {
              label: "直播",
              value: 4
            }
          ];
        }
      } else {
        this.entranceTypeList = [
          {
            label: "关键词",
            value: 1
          },
          {
            label: "二维码",
            value: 3
          },
          {
            label: "直播",
            value: 4
          },
          {
            label: "其他",
            value: 5
          }
        ];
      }
    },
    handleAvatarSuccess(res, file) {
      this.planForm.goodsImg = res.msg;
      this.isUploadGoodsImg = true;
      this.$message.success("上传成功");
    },
    beforeAvatarUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 10;
      if (!isLt2M) {
        this.$message.error("上传商品图片大小不能超过 10MB!");
      }
      this.uploadImgStatus = 1;
      return isLt2M;
    },
    entranceTypeChange(val, item) {
      this.$set(item, "keyword", "");
      this.$set(item, "entranceType", val);
      this.$forceUpdate(); //强制刷新
    },
    expressionFilter(e) {
      const newKeyword = e.keyword.replace(
          /\uD83C[\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g,
          ""
      );
      this.$set(e, "keyword", newKeyword);
    },
    inputUpdate() {
      this.$forceUpdate();
    },
    cutTask(index) {
      for (var i in this.planForm.planMessage) {
        if (index == i) {
          this.planForm.planMessage.splice(i, 1);
        }
      }
    },
    addTask() {
      let task = {};
      if (this.creatPlanType == "sales") {
        task = {
          keyword: "",
          payMoney: "",
          sku: "",
          entranceType: 1,
          taskNum: "1",
          buyNum: "1"
        };
      } else {
        task = {
          keyword: "",
          entranceType: 1,
          taskNum: "1", //新增
          taskType: {
            1: 0,
            2: 0,
            3: 0,
            4: 0,
            5: 0,
            6: 0,
            7: 0,
            8: 0
          }
        };
      }
      this.planForm.planMessage.push(task);
    },
    //发布时间设置
    initCurTime() {
      var now = new Date();
      this.setPlanTime.startTime = now.getTime();
      this.setPlanTime.endTime =
          new Date(new Date().toLocaleDateString()).getTime() +
          24 * 60 * 60 * 1000 -
          1;

      if (this.planForm.allotType == 3) {
        this.setPlanTime.endTime = "";
      }
    },
    changeTimeTab(type) {
      if (this.isForbidModify) {
        return;
      }
      this.planForm.allotType = type;
      this.initCurTime();
      if (this.planForm.allotType == 2) {
        this.selectDate();
        this.planForm.planOver = 1;
        let date = new Date(this.setPlanTime.startTime); //new Date(value*1000);根据时间戳格式进行选择乘1000或否
        let timeDate;
        let Y = date.getFullYear() + "-";
        let M =
            (date.getMonth() + 1 < 10
                ? "0" + (date.getMonth() + 1)
                : date.getMonth() + 1) + "-";
        let D =
            (date.getDate() < 10 ? "0" + date.getDate() : date.getDate()) + " ";
        timeDate = Y + M + D + "23:29:59";
        this.setPlanTime.endTime = new Date(timeDate).getTime();
        let overTimeDate = Y + M + D + "23:30:00";
        this.setPlanTime.overTime = new Date(overTimeDate).getTime();
        this.oldOverTime = JSON.parse(
            JSON.stringify(this.setPlanTime.overTime)
        );
      } else {
        this.planForm.planOver = 2;
        this.setPlanTime.overTime = "";
      }
    },
    changeStartTime() {
      if (this.planForm.planOver == 1) {
        if (this.setPlanTime.overTime - this.setPlanTime.startTime < 0) {
          return this.$message.error("终止时间不能小于开始时间");
        }
      }
    },
    changeDate() {
      if (this.setPlanTime.startTime - this.setPlanTime.endTime > 0) {
        this.$message.error("开始时间不能大于结束时间!");
        var now = new Date();
        this.setPlanTime.startTime = now.getTime();
        this.setPlanTime.endTime =
            new Date(new Date().toLocaleDateString()).getTime() +
            24 * 60 * 60 * 1000 -
            1;
        return;
      }
      if (this.planForm.planOver == 1) {
        if (this.setPlanTime.overTime - this.setPlanTime.endTime < 0) {
          this.setPlanTime.endTime =
              new Date(new Date().toLocaleDateString()).getTime() +
              24 * 60 * 60 * 1000 -
              1;
          return this.$message.error("终止时间不能小于结束时间");
        }
      }
    },
    changeOverTime(val) {
      if (this.planForm.allotType == 2) {
        if (this.setPlanTime.overTime < this.setPlanTime.endTime) {
          this.setPlanTime.overTime = moment(this.setPlanTime.endTime)
              .toDate()
              .getTime();
          return this.$message.error("终止时间不能小于结束时间");
        }
        let newOverTime = JSON.parse(JSON.stringify(this.setPlanTime.overTime));
        newOverTime = newOverTime / 1000;
        let flag = false;
        Object.keys(this.planForm.planTime).forEach((item, index) => {
          for (var i in this.planForm.planTime[item]) {
            if (newOverTime - parseInt(i) < 0) {
              if (this.planForm.planTime[item][i] > 0) {
                this.$message.error(
                    "该终止时间后面有分配数，请先置为0在设置终止时间"
                );
                this.setPlanTime.overTime = JSON.parse(
                    JSON.stringify(this.oldOverTime)
                );
                flag = true;
                return;
              }
            }
          }
        });
        if (!flag) {
          this.oldOverTime = JSON.parse(
              JSON.stringify(this.setPlanTime.overTime)
          );
        }
      } else {
        if (this.setPlanTime.overTime - this.setPlanTime.startTime < 0) {
          this.setPlanTime.overTime = "";
          return this.$message.error("终止时间不能小于开始时间");
        }
      }
    },
    changeManualAllocationTime(val) {
      // let date = new Date(this.setPlanTime.startTime); //new Date(value*1000);根据时间戳格式进行选择乘1000或否
      // let timeDate;
      // let Y = date.getFullYear() + '-';
      // let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
      // let D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
      //
      // let curCheckTime = this.setPlanTime.startTime / 1000
      // let curCheckDay = this.getDateOfDay(curCheckTime);
      // let today = new Date();
      // if(curCheckDay != today.getDate()) {
      //   let startTimeDate = Y + M + D + '00:00:00';
      //   this.setPlanTime.startTime = new Date(startTimeDate).getTime()
      // }
      if (val) {
        if (
            moment(this.setPlanTime.startTime).isBefore(
                moment(this.setPlanTime.endTime)
            )
        )
          return val;
        this.$message.error("开始时间不能大于结束时间");
        this.setPlanTime.startTime = moment(this.setPlanTime.endTime).add(
            -1,
            "days"
        );
      } else {
        // this.setPlanTime.startTime = moment().set('hour', 0).set('minute', 0).toDate().getTime()
      }

      // timeDate = Y + M + D + '23:29:59';
      // this.setPlanTime.endTime = new Date(timeDate).getTime()
      // let overTimeDate = Y + M + D + '23:30:00';
      // this.setPlanTime.overTime = new Date(overTimeDate).getTime()
      // this.oldOverTime = JSON.parse(JSON.stringify(this.setPlanTime.overTime))
    },
    changeManualAllocationEndTime(val) {
      if (val) {
        this.changeManualAllocationOverTime();
        if (moment(this.setPlanTime.startTime).isBefore(moment(val)))
          return val;
        this.setPlanTime.endTime = moment(this.setPlanTime.startTime).add(
            1,
            "days"
        );
        this.changeManualAllocationOverTime();
        this.$message.error("开始时间不能大于结束时间");
      } else {
        // this.setPlanTime.endTime = moment().set('hour', 23).set('minute', 59).toDate().getTime()
        // this.changeManualAllocationOverTime()
        // console.log(this.setPlanTime.endTime)
        // this.setPlanTime.endTime = new Date().getTime()
      }
    },
    changeManualAllocationOverTime() {
      this.setPlanTime.overTime = moment(this.setPlanTime.endTime)
          .toDate()
          .getTime();
      this.oldOverTime = JSON.parse(JSON.stringify(this.setPlanTime.overTime));
    },
    selectDate() {
      this.$forceUpdate();
      if (this.setPlanTime.startTime == "" && this.setPlanTime.endTime == "") {
        return;
      }
      // =============
      var startTimestamp = this.setPlanTime.startTime / 1000;
      var endTimestamp = this.setPlanTime.endTime / 1000;
      //获取哪天
      var startTimeOfDay = this.getDateOfDay(startTimestamp);
      var endTimeOfDay = this.getDateOfDay(endTimestamp);
      //获取开始时间在哪个小时
      var startTimeOfHours = this.getDateOfHours(startTimestamp);
      var endTimeOfHours = this.getDateOfHours(endTimestamp);
      //获取第几年
      var startTimeOYear = this.getDateOfYear(startTimestamp);
      var endTimeOYear = this.getDateOfYear(endTimestamp);
      //获取第几月
      var startTimeOfMonth = this.getDateOfMonth(startTimestamp);
      var endTimeOfMonth = this.getDateOfMonth(endTimestamp);
      //开始时间当天的小时差
      var curPeriod = 24 - startTimeOfHours;
      var timeJosn = {};
      var curTimeKey =
          startTimeOYear +
          "-" +
          startTimeOfMonth +
          "-" +
          startTimeOfDay +
          " " +
          startTimeOfHours +
          ":" +
          "00:00";

      var newCurTimeKey = this.dateToUnix(curTimeKey);

      //开始时间到结束时间相差几天
      var dayNum = endTimeOfDay - startTimeOfDay;
      //当dayNum=0时，开始时间跟结束时间在同一天

      //判断开始时间和结束时间是否在同一个月
      if (startTimeOfMonth == endTimeOfMonth) {
        //判断开始时间和结束时间是否在同一天
        if (dayNum == 0) {
          timeJosn[newCurTimeKey] = {};
          var now = new Date();
          var hour = now.getHours();
          let newPeriod = 24 - hour;
          if (startTimeOfDay != now.getDate()) {
            for (var i = 0; i < curPeriod; i++) {
              var date =
                  startTimeOYear +
                  "-" +
                  startTimeOfMonth +
                  "-" +
                  startTimeOfDay +
                  " " +
                  (parseInt(startTimeOfHours) + i) +
                  ":" +
                  "00:00";
              timeJosn[newCurTimeKey][this.dateToUnix(date)] = 0;
            }
          } else {
            for (var i = 1; i < newPeriod; i++) {
              var date =
                  startTimeOYear +
                  "-" +
                  startTimeOfMonth +
                  "-" +
                  startTimeOfDay +
                  " " +
                  (parseInt(hour) + i) +
                  ":" +
                  "00:00";
              timeJosn[newCurTimeKey][this.dateToUnix(date)] = 0;
            }
          }
        } else {
          //当开始时间跟结束时间相差一天以上，就要把当天跟后面几天合在一起
          timeJosn[newCurTimeKey] = {};
          for (var i = 1; i < curPeriod; i++) {
            var date =
                startTimeOYear +
                "-" +
                startTimeOfMonth +
                "-" +
                startTimeOfDay +
                " " +
                (parseInt(startTimeOfHours) + i) +
                ":" +
                "00:00";
            timeJosn[newCurTimeKey][this.dateToUnix(date)] = 0;
          }
          //第二天开始
          for (var i = 0; i < dayNum; i++) {
            var timeKey =
                startTimeOYear +
                "-" +
                startTimeOfMonth +
                "-" +
                (parseInt(startTimeOfDay) + (i + 1)) +
                " " +
                startTimeOfHours +
                ":" +
                "00:00";
            var newTimeKey = this.dateToUnix(timeKey);
            timeJosn[newTimeKey] = {};
            for (var j = 0; j < 24; j++) {
              var date =
                  startTimeOYear +
                  "-" +
                  startTimeOfMonth +
                  "-" +
                  (parseInt(startTimeOfDay) + (i + 1)) +
                  " " +
                  j +
                  ":" +
                  "00:00";
              timeJosn[newTimeKey][this.dateToUnix(date)] = 0;
            }
          }
        }
      } else {
        //开始时间那个月的总天数
        var startTimeOfMonthAllDay = this.getMonDay(this.setPlanTime.startTime);
        //结束时间那个月的第几天
        var endtDateOfNowDay = this.getNowDay(this.setPlanTime.endTime);

        timeJosn[newCurTimeKey] = {};
        for (var i = 1; i < curPeriod; i++) {
          var date =
              startTimeOYear +
              "-" +
              startTimeOfMonth +
              "-" +
              startTimeOfDay +
              " " +
              (parseInt(startTimeOfHours) + i) +
              ":" +
              "00:00";
          timeJosn[newCurTimeKey][this.dateToUnix(date)] = 0;
        }
        var curDayNum = startTimeOfMonthAllDay - startTimeOfDay;
        for (var i = 0; i < curDayNum; i++) {
          var timeKey =
              startTimeOYear +
              "-" +
              startTimeOfMonth +
              "-" +
              (parseInt(startTimeOfDay) + (i + 1)) +
              " " +
              startTimeOfHours +
              ":" +
              "00:00";
          var newTimeKey = this.dateToUnix(timeKey);
          timeJosn[newTimeKey] = {};
          for (var j = 0; j < 24; j++) {
            var date =
                startTimeOYear +
                "-" +
                startTimeOfMonth +
                "-" +
                (parseInt(startTimeOfDay) + (i + 1)) +
                " " +
                j +
                ":" +
                "00:00";
            timeJosn[newTimeKey][this.dateToUnix(date)] = 0;
          }
        }
        //获取下个月的
        for (var i = 0; i < endtDateOfNowDay; i++) {
          var timeKey =
              endTimeOYear +
              "-" +
              endTimeOfMonth +
              "-" +
              (i + 1) +
              " " +
              endTimeOfHours +
              ":" +
              "00:00";
          var newTimeKey = this.dateToUnix(timeKey);
          timeJosn[newTimeKey] = {};
          for (var j = 0; j < 24; j++) {
            var date =
                endTimeOYear +
                "-" +
                endTimeOfMonth +
                "-" +
                (i + 1) +
                " " +
                j +
                ":" +
                "00:00";
            timeJosn[newTimeKey][this.dateToUnix(date)] = 0;
          }
        }
      }

      this.planForm.planTime = timeJosn;
      this.totalAllocation();
    },
    totalAllocation() {
      let totalNumber = 0;
      Object.keys(this.planForm.planTime).forEach(item => {
        Object.keys(this.planForm.planTime[item]).forEach(ite => {
          totalNumber += this.planForm.planTime[item][ite];
        });
      });
      this.totalAllotNum = totalNumber;
    },

    countIntendOrderNum() {
      var ordNumber = 0;
      let number = 0;
      this.planForm.planMessage.forEach((item, index) => {
        ordNumber += parseInt(item.taskNum);
        for (const i in item.taskType) {
          number += parseInt(item.taskType[i]);
        }
      });
      this.intendOrderNum = ordNumber;
      this.trafficOrderNum = number;
      if (this.creatPlanType === "sales") {
        return ordNumber;
      } else {
        return number;
      }
    },
    changeAllotNum(timeItem, itemKey) {
      this.totalAllocation();
      if (this.creatPlanType === "sales") {
        if (this.totalAllotNum > this.intendOrderNum) {
          this.isForbidEditNum = true;
          this.$nextTick(() => {
            this.$set(timeItem, itemKey, 0);
            this.totalAllocation();
          });
          this.$message.error("分配数不能超过计划中的单数!");
        } else {
          this.isForbidEditNum = false;
        }
      } else {
        if (this.totalAllotNum > this.trafficOrderNum) {
          this.isForbidEditNum = true;
          this.$nextTick(() => {
            this.$set(timeItem, itemKey, 0);
            this.totalAllocation();
          });
          this.$message.error("分配数不能超过计划中的单数!");
        } else {
          this.isForbidEditNum = false;
        }
      }

      let newOverTime = JSON.parse(JSON.stringify(this.setPlanTime.overTime));
      newOverTime = newOverTime / 1000;
      if (newOverTime - parseInt(itemKey) < 0) {
        this.isForbidEditNum = true;
        this.$nextTick(() => {
          this.$set(timeItem, itemKey, 0);
          this.totalAllocation();
        });
        this.$message.error("不能在终止时间后进行分配");
      }
      setTimeout(() => {
        this.isForbidEditNum = false;
      }, 5000);
    },
    clickRemarkText(content) {
      if (this.planForm.remark.length >= 150) {
        return;
      }
      this.planForm.remark += content + ";";
    },

    dateToUnix(string) {
      var f = string.split(" ", 2);
      var d = (f[0] ? f[0] : "").split("-", 3);
      var t = (f[1] ? f[1] : "").split(":", 3);
      return (
          new Date(
              parseInt(d[0], 10) || null,
              (parseInt(d[1], 10) || 1) - 1,
              parseInt(d[2], 10) || null,
              parseInt(t[0], 10) || null,
              parseInt(t[1], 10) || null,
              parseInt(t[2], 10) || null
          ).getTime() / 1000
      );
    },
    getNowDay(mydate) {
      var d = new Date(mydate);
      return d.getDate();
    },
    //获取当月总共几天
    getMonDay(mydate) {
      var d = new Date(mydate);
      //d.getMonth()+1月份索引从0开始,天数索引从1开始，第0天即代表最后一天
      var allDays = new Date(d.getFullYear(), d.getMonth() + 1, 0).getDate();
      return allDays;
    },
    //获取小时
    getDateOfHours(val) {
      var date = new Date(val * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
      var h = date.getHours();
      return h;
    },
    //获取月
    getDateOfMonth(val) {
      var date = new Date(val * 1000);
      var m =
          date.getMonth() + 1 < 10
              ? "0" + (date.getMonth() + 1)
              : date.getMonth() + 1;
      return m;
    },
    //获取天
    getDateOfDay(val) {
      var date = new Date(val * 1000);
      var d = date.getDate();
      return d;
    },
    getDateOfYear(val) {
      var date = new Date(val * 1000);
      var y = date.getFullYear();
      return y;
    },
    formatDate(now) {
      let year = now.getFullYear();
      let month = now.getMonth() + 1;
      let date = now.getDate();
      let hour = now.getHours();
      let minute = now.getMinutes();
      let second = now.getSeconds();
      return year + "." + month + "." + date;
    },

    //取月日
    getMonthAndDay(time) {
      var date = new Date(time * 1000);
      var m =
          date.getMonth() + 1 < 10
              ? "0" + (date.getMonth() + 1)
              : date.getMonth() + 1;
      var d = date.getDate();
      return m + "-" + d;
    },
    //----地区---
    showAreaDialog() {
      this.isShowAreaDialog = true;
    },
    handleCheckAllChange(value, item) {
      item.checkedCities = value ? item.province : [];
      item.isIndeterminate = false;
      var flag = true;
      for (var i in this.provinceOpitons) {
        if (!this.provinceOpitons[i].checkAll) {
          flag = false;
        }
      }
      this.isIndeterminate = flag == false ? true : false;
      this.checkAll = flag == false ? false : true;
    },
    handleCheckedProvinceChange(value, item) {
      let checkedCount = value.length;
      item.checkAll = checkedCount === item.province.length;
      item.isIndeterminate =
          checkedCount > 0 && checkedCount < item.province.length;
    },
    selectAll() {
      this.checkAll != this.checkAll;
      if (this.checkAll) {
        for (var i in this.provinceOpitons) {
          this.provinceOpitons[i].checkedCities = this.provinceOpitons[
              i
              ].province;
          this.provinceOpitons[i].isIndeterminate = false;
          this.provinceOpitons[i].checkAll = true;
        }
        this.isIndeterminate = false;
      } else {
        for (var i in this.provinceOpitons) {
          this.provinceOpitons[i].checkedCities = [];
          this.provinceOpitons[i].isIndeterminate = false;
          this.provinceOpitons[i].checkAll = false;
        }
      }
    },
    saveAreaData() {
      this.planForm.placementArea = "";
      var isSelectAll = false;
      for (var i in this.provinceOpitons) {
        if (!this.provinceOpitons[i].checkAll) {
          isSelectAll = true;
        }

        if (this.provinceOpitons[i].checkedCities.length > 0) {
          this.planForm.placementArea +=
              this.provinceOpitons[i].checkedCities.join(",") + ",";
        }
      }
      this.planForm.placementArea = isSelectAll
          ? this.planForm.placementArea.substring(
              0,
              this.planForm.placementArea.length - 1
          )
          : "";

      this.isShowAreaDialog = false;
    },
    //-----接单设置-----
    getTagsDefaultPrice(title) {
      for (let i in this.tagsDefaultPrice) {
        if (this.tagsDefaultPrice[i].title == title) {
          return this.tagsDefaultPrice[i].default_price;
        }
      }
    },
    changeAge(val) {
      if (val.length > 1) {
        if (val.indexOf("99") >= 0) {
          for (var i in this.ageIdArr) {
            if (this.ageIdArr[i] == "99") {
              this.ageIdArr.splice(i, 1);
            }
          }
        }
      }
      this.planForm.ageId = this.ageIdArr.join(",");
    },
    formValidate() {
      for (var i in this.originalShopNameList) {
        if (this.planForm.shopId == this.originalShopNameList[i].id) {
          if (this.planForm.shopType != this.originalShopNameList[i].type) {
            this.$message.error(
                "您选择的店铺类型与抓取的店铺类型不一致，请修改！"
            );
            return false;
          }

          // if (this.planForm.shopName.replace(/\s*/g,'') != this.originalShopNameList[i].name.replace(/\s*/g,'')) {
          //     this.$message.error('您选择的店铺与抓取的店铺不一致，请修改！')
          //     return
          // }
        }
      }
      for (var i in this.planForm.planMessage) {
        if (this.planForm.planMessage[i].entranceType == 1) {
          if (this.planForm.planMessage[i].keyword == "") {
            this.$message.error("关键词不能为空！");
            return false;
          }
        }
        if (this.planForm.planMessage[i].entranceType == 2) {
          if (this.planForm.planMessage[i].keyword == "") {
            this.$message.error("抖口令不能为空！");
            return false;
          }
        }
        if (this.planForm.planMessage[i].entranceType == 3) {
          if (this.planForm.planMessage[i].keyword == "") {
            this.$message.error("二维码不能为空！");
            return false;
          }
        }
        if (this.creatPlanType == "sales") {
          if (this.planForm.planMessage[i].payMoney == "") {
            this.$message.error("拍下价格不能为空！");
            return false;
          }
        }
      }
      if (this.planForm.allotType == 2) {
        if (this.totalAllotNum < this.intendOrderNum) {
          this.$message.error("还有未分配的单数！");
          return false;
        }
        // if (this.totalAllotNum > this.intendOrderNum) {
        //   this.$message.error('已分配总计超过计划中的单数！')
        //   return false
        // }
        if (this.creatPlanType === "sales") {
          if (this.totalAllotNum > this.intendOrderNum) {
            this.$message.error("已分配总计超过计划中的单数！");
            return false;
          }
        } else {
          if (this.totalAllotNum > this.trafficOrderNum) {
            this.$message.error("已分配总计超过计划中的单数！");
            return false;
          }
        }
      }
      if (this.isUploadGoodsImg) {
        if (this.planForm.goodsImg.indexOf("goods") < 0) {
          this.$message.error("商品主图未上传成功，请稍等或者重新上传");
          return false;
        }
      }
      if (!this.planForm.remark) {
        this.$message.error("请填写商家要求!");
        return false;
      }
      if (this.creatPlanType == "sales") {
        if (
            this.showCheckContentArr.indexOf(this.planForm.shopType) >= 0 &&
            this.checkContentStatus
        ) {
          if (
              this.planForm.checkContent.length >= 1 &&
              this.planForm.checkContent.length < 5
          ) {
            this.$message.error("商品详情页文本字数要为5个");
            return false;
          }
          if (this.planForm.checkContent.indexOf(" ") >= 0) {
            this.$message.error("商品详情页文本不能包含空格");
            return false;
          }
        }
      } else {
        var now = new Date();
        var startTimestamp = this.setPlanTime.startTime / 1000;
        var endTimestamp = this.setPlanTime.endTime / 1000;
        var startTimeOfHours = this.getDateOfHours(startTimestamp);
        var endTimeOfHours = this.getDateOfHours(endTimestamp);
        var startTimeOfDay = this.getDateOfDay(startTimestamp);
        var endTimeOfDay = this.getDateOfDay(endTimestamp);
        var dayNum = endTimeOfDay - startTimeOfDay;
        if (this.planForm.allotType == 1) {
          if (dayNum == 0) {
            if (startTimeOfHours < 6 || endTimeOfHours < 6) {
              this.$message.error("浏览单任务时间不能在00:00:00~06:00:00之间!");
              this.setPlanTime.startTime = now.getTime();
              this.setPlanTime.endTime =
                  new Date(new Date().toLocaleDateString()).getTime() +
                  24 * 60 * 60 * 1000 -
                  1;

              return false;
            }
          } else {
            this.$message.error("浏览单任务时间不能在00:00:00~06:00:00之间!");
            this.setPlanTime.startTime = now.getTime();
            this.setPlanTime.endTime =
                new Date(new Date().toLocaleDateString()).getTime() +
                24 * 60 * 60 * 1000 -
                1;

            return false;
          }
        }
      }
      return true;
    },
    creatPlan() {
      if (this.planForm.shopId) {
        this.shopNameList.map(item => {
          if (item.id == this.planForm.shopId) {
            // 裁剪店铺名称
            let arrshopname = item.name.split("-");
            let shopName = arrshopname[1];
            if (arrshopname.length > 2) {
              arrshopname.forEach((item, index) => {
                if (index > 1) {
                  shopName += "-" + item
                }
              })
            } else {
              shopName = shopName.trim()
            }
            if (this.planForm.shopName.trim() != shopName) {
              this.$message.error("店铺名称与商品店铺名称不一致");
              return false;
            } else {
              // 店铺名与选着的商品的店铺名称一致
              if (this.creatPlanType == "flow") {
                var shopTypeArr = [20];
                if (shopTypeArr.indexOf(this.planForm.shopType) < 0) {
                  this.$message.error("只能发布抖音的商品！");
                  return;
                }
              }
              this.$refs["planForm"].validate(valid => {
                if (valid) {
                  if (!this.formValidate()) return;
                  let discount = this.serviceFeeList["discount"];
                  let serviceFeeType = {
                    20: "service_fee_onedragmore"
                  };
                  let serviceFee = serviceFeeType[this.planForm.shopType];
                  let curServiceFeeList = this.serviceFeeList[serviceFee];
                  let priceArr = [];

                  this.payPlanInfo.otherService = {
                    sex: {},
                    age: {},
                    model: {},
                    credit: {},
                    zqd: {}
                  };
                  this.payPlanInfo.capital = "";
                  this.payPlanInfo.commission = "";
                  this.payPlanInfo.freezeMoney = 0;

                  let sexPriceText = "";
                  let agePriceText = "";
                  let modelPriceText = "";
                  let creditPriceText = "";
                  let zqdPriceText = "";
                  let tkPriceText = "";

                  let sexPriceNum = 0;
                  let agePriceNum = 0;
                  let modelPriceNum = 0;
                  let creditPriceNum = 0;
                  let zqdPriceNum = 0;
                  let tkPriceNum = 0;

                  let commissionArr = [];
                  let flowTaskTypeList = [];
                  let flowTaskAllNum = 0;
                  let priceFailStatus = false;
                  this.planForm.planMessage.forEach((item, index) => {
                    if (this.creatPlanType == "sales") {
                      //本金
                      this.payPlanInfo.capital +=
                          (index > 0 ? "+" : "") +
                          ("(" +
                              parseFloat(item.payMoney).toFixed(2) +
                              "*" +
                              item.buyNum +
                              "*" +
                              item.taskNum +
                              ")");
                      if (this.planForm.rebateType != 1) {
                        this.payPlanInfo.freezeMoney +=
                            parseFloat(item.payMoney) *
                            parseInt(item.buyNum) *
                            parseInt(item.taskNum);
                      }
                      this.payPlanInfo.freezeMoney = parseFloat(
                          this.payPlanInfo.freezeMoney
                      );
                    } else {
                      for (var i in item.taskType) {
                        if (this.isBlank(flowTaskTypeList[i])) {
                          flowTaskTypeList[i] = 0;
                        }
                        flowTaskTypeList[i] += parseInt(item.taskType[i]);
                      }
                    }
                  });
                  //流量任务总数
                  for (var i in flowTaskTypeList) {
                    flowTaskAllNum += parseInt(flowTaskTypeList[i]);
                  }
                  var sexIsShow = false;
                  var ageIsSHow = false;
                  var creditIsShow = false;
                  var modelIsSHow = false;
                  var zqdIsShow = false;
                  var tkIsSHow = false;
                  zqdIsShow = this.planForm.zqd == "2" ? false : true;
                  tkIsSHow = this.planForm.tk == "2" ? false : true;
                  if (this.planType == "pay") {
                    sexIsShow = this.planForm.sexId == "99" ? false : true;
                    ageIsSHow = this.ageIdArr.indexOf("99") >= 0 ? false : true;
                    creditIsShow =
                        this.planForm.creditId == "99" ? false : true;
                    modelIsSHow = this.planForm.modelId == "99" ? false : true;
                  } else {
                    if (this.tagsList.sex_list.status == 1) {
                      sexIsShow = this.planForm.sexId == "99" ? false : true;
                    } else {
                      sexIsShow = false;
                      this.planForm.sexId == "99";
                    }
                    if (this.tagsList.age_list.status == 1) {
                      ageIsSHow =
                          this.ageIdArr.indexOf("99") >= 0 ? false : true;
                    } else {
                      ageIsSHow = false;
                      this.planForm.ageId = "99";
                    }
                    if (this.tagsList.model_list.status == 1) {
                      modelIsSHow =
                          this.planForm.modelId == "99" ? false : true;
                    } else {
                      modelIsSHow = false;
                      this.planForm.modelId = "99";
                    }
                    if (this.tagsList.credit_list.status == 1) {
                      creditIsShow =
                          this.planForm.creditId == "99" ? false : true;
                    } else {
                      creditIsShow = false;
                      this.planForm.creditId = "99";
                    }
                  }
                  //生成其他服务收费
                  this.planForm.planMessage.forEach((item, index) => {
                    //流量每个类型的总数*价格，所以commissionArr只push一次就行了
                    if (this.creatPlanType == "flow") {
                      commissionArr = [];
                    }
                    curServiceFeeList.forEach((cell, cellIndex) => {
                      if (this.creatPlanType == "sales") {
                        if (cell.pay_type == 1) {
                          priceArr.push(cell);
                          if (
                              (parseFloat(item.payMoney) * parseFloat(item.buyNum)).toFixed(2) <=
                              parseFloat(cell.title.split("-")[1]) &&
                              (parseFloat(item.payMoney) * parseFloat(item.buyNum)).toFixed(2) >
                              parseFloat(cell.title.split("-")[0])
                          ) {
                            commissionArr.push({
                              num: parseInt(item.taskNum),
                              price: (
                                  (parseFloat(cell.default_price) * discount) /
                                  10
                              ).toFixed(2)
                            });
                          }
                        }
                      } else {
                        if (cell.pay_type == 3) {
                          commissionArr.push(cell.default_price);
                        }
                      }
                      if (cell.pay_type == 2) {
                        if (cell.title.indexOf("性别") >= 0) {
                          if (this.creatPlanType == "sales") {
                            sexPriceText +=
                                "(" +
                                item.taskNum +
                                "*" +
                                cell.default_price +
                                ") + ";
                            sexPriceNum +=
                                parseInt(item.taskNum) *
                                parseFloat(cell.default_price);
                          } else {
                            sexPriceText =
                                flowTaskAllNum + "*" + cell.default_price;
                            sexPriceNum =
                                parseInt(flowTaskAllNum) *
                                parseFloat(cell.default_price);
                          }

                          this.payPlanInfo.otherService.sex = {
                            isShow: sexIsShow,
                            name: "推手性别",
                            price: sexPriceText,
                            money: parseFloat(sexPriceNum).toFixed(2)
                          };
                        }
                        if (cell.title.indexOf("年龄") >= 0) {
                          if (this.creatPlanType == "sales") {
                            agePriceText +=
                                "(" +
                                item.taskNum +
                                "*" +
                                cell.default_price +
                                ") + ";
                            agePriceNum +=
                                parseInt(item.taskNum) *
                                parseFloat(cell.default_price);
                          } else {
                            agePriceText =
                                flowTaskAllNum + "*" + cell.default_price;
                            agePriceNum =
                                parseInt(flowTaskAllNum) *
                                parseFloat(cell.default_price);
                          }

                          this.payPlanInfo.otherService.age = {
                            isShow: ageIsSHow,
                            name: "推手年龄",
                            price: agePriceText,
                            money: parseFloat(agePriceNum).toFixed(2)
                          };
                        }
                        if (cell.title.indexOf("手机机型") >= 0) {
                          if (this.creatPlanType == "sales") {
                            modelPriceText +=
                                "(" +
                                item.taskNum +
                                "*" +
                                cell.default_price +
                                ") + ";
                            modelPriceNum +=
                                parseInt(item.taskNum) *
                                parseFloat(cell.default_price);
                          } else {
                            modelPriceText =
                                flowTaskAllNum + "*" + cell.default_price;
                            modelPriceNum =
                                parseInt(flowTaskAllNum) *
                                parseFloat(cell.default_price);
                          }

                          this.payPlanInfo.otherService.model = {
                            isShow: modelIsSHow,
                            name: "推手机型",
                            price: modelPriceText,
                            money: parseFloat(modelPriceNum).toFixed(2)
                          };
                        }
                        if (cell.title.indexOf("信用") >= 0) {
                          if (this.creatPlanType == "sales") {
                            creditPriceText +=
                                "(" +
                                item.taskNum +
                                "*" +
                                cell.default_price +
                                ") + ";
                            creditPriceNum +=
                                parseInt(item.taskNum) *
                                parseFloat(cell.default_price);
                          } else {
                            creditPriceText =
                                flowTaskAllNum + "*" + cell.default_price;
                            creditPriceNum =
                                parseInt(flowTaskAllNum) *
                                parseFloat(cell.default_price);
                          }
                          this.payPlanInfo.otherService.credit = {
                            isShow: creditIsShow,
                            name: "推手信用",
                            price: creditPriceText,
                            money: parseFloat(creditPriceNum).toFixed(2)
                          };
                        }
                        if (cell.title.indexOf("预约增权") >= 0) {
                          if (this.creatPlanType == "sales") {
                            zqdPriceText +=
                                "(" +
                                item.taskNum +
                                "*" +
                                cell.default_price +
                                ") + ";
                            zqdPriceNum +=
                                parseInt(item.taskNum) *
                                parseFloat(cell.default_price);
                          } else {
                            zqdPriceText =
                                flowTaskAllNum + "*" + cell.default_price;
                            zqdPriceNum =
                                parseInt(flowTaskAllNum) *
                                parseFloat(cell.default_price);
                          }
                          this.payPlanInfo.otherService.zqd = {
                            isShow: zqdIsShow,
                            name: "增权单",
                            price: zqdPriceText,
                            money: parseFloat(zqdPriceNum).toFixed(2)
                          };
                        }
                        if (this.creatPlanType == "sales") {
                          if (cell.title.indexOf("淘客检查") >= 0) {
                            tkPriceText +=
                                "(" +
                                item.taskNum +
                                "*" +
                                cell.default_price +
                                ") + ";
                            tkPriceNum +=
                                parseInt(item.taskNum) *
                                parseFloat(cell.default_price);
                            let tk = {
                              isShow: tkIsSHow,
                              name: "淘客",
                              price: tkPriceText,
                              money: parseFloat(tkPriceNum).toFixed(2)
                            };
                            this.$set(this.payPlanInfo.otherService, "tk", tk);
                          }
                        }
                      }
                    });
                    if (this.creatPlanType == "sales") {
                      if (priceArr.length == 0) {
                        this.$message.error("不存在对应的价格区间！");
                        priceFailStatus = true;
                        return false;
                      }
                      let maxMoney = parseInt(
                          priceArr[priceArr.length - 1].title.split("-")[1]
                      );
                      if (
                          parseInt(item.payMoney) * parseInt(item.buyNum) >
                          maxMoney
                      ) {
                        this.$message.error("不存在对应的价格区间！");
                        priceFailStatus = true;
                        return false;
                      }
                    }
                  });
                  if (priceFailStatus) {
                    return;
                  }
                  this.payPlanInfo.freezeMoney = parseFloat(
                      this.payPlanInfo.freezeMoney
                  );
                  //处理其他服务，是否展示，去掉多余的+
                  Object.values(this.payPlanInfo.otherService).forEach(
                      (item, index) => {
                        if(item.price){

                          if (item.isShow) {
                            this.isShowOtherService = true;
                            this.payPlanInfo.freezeMoney += parseFloat(item.money);
                          }
                          if (this.creatPlanType == "sales") {
                            let textLastIndex = item.price.lastIndexOf("+");
                            item.price = item.price.substring(0, textLastIndex - 1);
                          }

                        }
                      }
                  );
                  this.payPlanInfo.freezeMoney = parseFloat(
                      this.payPlanInfo.freezeMoney
                  );
                  //指定时间
                  let startTimeFormat = this.formatDate(
                      new Date(this.setPlanTime.startTime)
                  );
                  let endTimeFormat = this.setPlanTime.endTime
                      ? this.formatDate(new Date(this.setPlanTime.endTime))
                      : "";
                  let timeTypeName =
                      "(" + this.tabsList[this.planForm.allotType - 1].name + ")";
                  this.payPlanInfo.planTime = endTimeFormat
                      ? startTimeFormat + "--" + endTimeFormat
                      : startTimeFormat;
                  this.payPlanInfo.planTime =
                      this.payPlanInfo.planTime + timeTypeName;
                  //佣金
                  commissionArr.forEach((c, cIndex) => {
                    if (this.creatPlanType == "sales") {
                      this.payPlanInfo.commission +=
                          (cIndex > 0 ? "+" : "") +
                          ("(" + c.num + "*" + c.price + ")");
                      this.payPlanInfo.freezeMoney += c.num * c.price;
                    } else {
                      this.payPlanInfo.commission +=
                          (cIndex > 0 ? "+" : "") +
                          ("(" + flowTaskTypeList[cIndex + 1] + "*" + c + ")");
                      this.payPlanInfo.freezeMoney +=
                          flowTaskTypeList[cIndex + 1] * parseFloat(c);
                    }
                  });
                  this.payPlanInfo.freezeMoney = this.payPlanInfo.freezeMoney.toFixed(
                      2
                  );
                  this.isShowPayPlanDialog = true;
                } else {
                  this.$message.error("创建的计划信息不完善，请先填写");
                }
              });
            }
          }
        });
      } else {
        this.$message.error("请选择店铺名称");
      }
    },
    payPlan() {
      if (this.payPlanInfo.freezeMoney == 0) {
        return this.$message.error("金额不能为0");
      }
      this.planForm.startTime = JSON.parse(
          JSON.stringify(Math.floor(this.setPlanTime.startTime / 1000))
      );
      this.planForm.endTime =
          this.planForm.allotType == 3
              ? ""
              : JSON.parse(
              JSON.stringify(Math.floor(this.setPlanTime.endTime / 1000))
              );
      this.planForm.overTime =
          this.planForm.planOver == 2
              ? ""
              : JSON.parse(
              JSON.stringify(Math.floor(this.setPlanTime.overTime / 1000))
              );
      if (this.planForm.placementArea) {
        this.planForm.placementArea = "+" + this.planForm.placementArea;
      }
      if (this.planType == "pay") {
        this.planForm.payType = "creating";
        this.planForm.id = this.planId;
      } else {
        this.planForm.payType = "";
      }
      this.submitLoading = true;
      if (this.creatPlanType == "sales") {
        apiCreateSalePlan(this.planForm)
            .then(res => {
              if (res.code == 1 || res.code == 1001) {
                this.submitLoading = false;
                this.isShowPayPlanDialog = false;
                let _this = this
                return this.$alert(res.msg, '提示', {
                  confirmButtonText: '确定',
                  callback: action => {
                    _this.$router.push("./salesPlanList");
                  }
                })
              } else {
                this.submitLoading = false;
                this.$message.error(res.msg);
              }
            })
            .catch(res => {
              this.submitLoading = false;
              this.isShowPayPlanDialog = false;
              this.$message.error(res.msg);
            });
      } else {
        apiCreateFlowPlan(this.planForm)
            .then(res => {
              if (res.code == 1 || res.code == 1001) {
                this.submitLoading = false;
                this.isShowPayPlanDialog = false;
                let _this = this
                return this.$alert(res.msg, '提示', {
                  confirmButtonText: '确定',
                  callback: action => {
                    _this.$router.push("./flowPlanList");
                  }
                })
              } else {
                this.submitLoading = false;
                this.$message.error(res.msg);
              }
            })
            .catch(res => {
              this.submitLoading = false;
              this.isShowPayPlanDialog = false;
              this.$message.error(res.msg);
            });
      }
    },
    getPlanDetail() {
      if (this.planType == "pay") {
        this.isForbidModify = true;
        this.isForbidRevise = true;
        this.isForbidEditNum = true;
      } else {
        this.isForbidRevise = true;
      }

      var areaType = 1;
      if (this.creatPlanType == "sales") {
        this.$isClick(true);
        apiSaleDetail({
          token: this.userToken,
          id: this.planId
        })
            .then(res => {
              this.$isClick(false);
              if (res.code == 1) {
                this.analyzePlanData(res, areaType);
              } else {
                this.$message.error(res.msg);
              }
            })
            .catch(res => {
              this.$isClick(false);
              this.$message.error(res.msg);
            });
      } else {
        this.$isClick(true);
        apiFlowDetail({
          token: this.userToken,
          id: this.planId
        })
            .then(res => {
              this.$isClick(false);
              if (res.code == 1) {
                this.analyzePlanData(res, areaType);
              } else {
                this.$message.error(res.msg);
              }
            })
            .catch(res => {
              this.$isClick(false);
              this.$message.error(res.msg);
            });
      }
    },
    analyzePlanData(res, areaType) {
      if (res.msg.placement_area == "[]" || res.msg.placement_area == "") {
        this.planForm.placementArea = "";
      } else {
        var ite = unescape(res.msg.placement_area.replace(/\u/g, "%u"));
        ite = ite.replace(/\\/g, "");
        ite = ite.replace(/\"/g, "");

        if (ite.indexOf("-") >= 0) {
          ite = ite.replace(/\-/g, "");
          areaType = 2;
        } else {
          ite = ite.replace(/\+/g, "");
          areaType = 1;
        }
        var provinceArr = ite.split(",");
        for (var z in this.provinceOpitons) {
          this.provinceOpitons[z].checkedCities = [];
          this.provinceOpitons[z].isIndeterminate = false;
          this.provinceOpitons[z].checkAll = false;
        }
        for (var province in this.provinceOpitons) {
          for (var i in provinceArr) {
            for (var j in this.provinceOpitons[province].province) {
              if (
                  provinceArr[i] == this.provinceOpitons[province].province[j]
              ) {
                this.provinceOpitons[province].checkedCities.push(
                    provinceArr[i]
                );
                if (
                    this.provinceOpitons[province].checkedCities.length ==
                    this.provinceOpitons[province].province.length
                ) {
                  this.provinceOpitons[province].isIndeterminate = false;
                } else {
                  this.provinceOpitons[province].isIndeterminate = true;
                }
                this.provinceOpitons[province].checkAll = true;
              }
            }
          }
          if (this.provinceOpitons[province].checkedCities.length > 0) {
            this.planForm.placementArea +=
                this.provinceOpitons[province].checkedCities.join(",") + ",";
          }
        }
        if (areaType == 2) {
          this.planForm.placementArea = "";
          for (var x in this.provinceOpitons) {
            var newArr = [];
            var checkedCitiesArr = this.provinceOpitons[x].checkedCities;
            if (checkedCitiesArr.length == 0) {
              this.provinceOpitons[x].checkedCities = this.provinceOpitons[
                  x
                  ].province;
            } else {
              for (var j in this.provinceOpitons[x].province) {
                if (
                    checkedCitiesArr.indexOf(
                        this.provinceOpitons[x].province[j]
                    ) < 0
                ) {
                  newArr.push(this.provinceOpitons[x].province[j]);
                }
              }
              this.provinceOpitons[x].checkedCities = newArr;
            }
            if (
                this.provinceOpitons[x].checkedCities.length ==
                this.provinceOpitons[x].province.length
            ) {
              this.provinceOpitons[x].isIndeterminate = false;
            } else {
              this.provinceOpitons[x].isIndeterminate = true;
            }
            if (this.provinceOpitons[x].checkedCities.length == 0) {
              this.provinceOpitons[x].checkAll = false;
              this.provinceOpitons[x].isIndeterminate = false;
            } else {
              this.provinceOpitons[x].checkAll = true;
            }
            if (this.provinceOpitons[x].checkedCities.length > 0) {
              this.planForm.placementArea +=
                  this.provinceOpitons[x].checkedCities.join(",") + ",";
            }
          }
        }
      }
      // this.isForbidModify = false
      this.planForm.placementArea = this.planForm.placementArea.substring(
          0,
          this.planForm.placementArea.length - 1
      );
      this.planForm.shopId = res.msg.merchant_shop.id; //店铺名称
      this.planForm.planName = res.msg.plan_name; //计划名称
      this.planForm.goodsImg = res.msg.goods_info.goods_img; //图片路径
      this.planForm.goodsUrl = res.msg.goods_info.goods_url; //商品url
      this.planForm.goodsTitle = res.msg.goods_info.goods_title; //商品标题
      this.planForm.shopName = res.msg.merchant_shop.name; //店铺名称
      this.planForm.goodsSeller = res.msg.merchant_shop.seller_name; //掌柜名称
      this.planForm.showMoney = res.msg.show_money; //搜索展示价格
      this.planForm.payPerson = res.msg.pay_person; //付款人数
      this.planForm.payMoney = res.msg.pay_money; //拍下单价
      this.planForm.shopType = res.msg.goods_info.shop_type; //商品类别
      this.planForm.tk = res.msg.tk_check_type
          ? res.msg.tk_check_type.toString()
          : "2"; //淘客
      this.planForm.goodsAddress = res.msg.goods_info.goods_address;
      this.planForm.productId = res.msg.goods_info.product_id;
      this.planForm.remark = res.msg.remark;
      this.planForm.sexId =
          res.msg.sex_id == 99 ? res.msg.sex_id.toString() : res.msg.sex_id;
      this.ageIdArr = [];
      if (res.msg.age_id == 99) {
        this.ageIdArr.push("99");
      } else {
        var idArr = res.msg.age_id.toString().split(",");
        for (var idItem in idArr) {
          this.ageIdArr.push(parseInt(idArr[idItem]));
        }
      }
      this.planForm.creditId =
          res.msg.credit_id == 99
              ? res.msg.credit_id.toString()
              : res.msg.credit_id;
      this.planForm.zqd = res.msg.zqd;
      this.planForm.zqdType = !res.msg.zqd_type
          ? "0"
          : res.msg.zqd_type.toString();
      this.planForm.modelId =
          res.msg.model_id == 99 ? res.msg.model_id.toString() : res.msg.model_id;
      this.planForm.allotType = parseInt(res.msg.allot_type);
      this.planForm.checkContent = res.msg.check_content
          ? res.msg.check_content
          : "";
      this.platFormTypeChange();
      if (res.msg.over_time !== "") {
        if (res.msg.over_time == 0) {
          this.planForm.planOver = 2;
          this.setPlanTime.overTime = "";
        } else {
          this.planForm.planOver = 1;
          this.setPlanTime.overTime = "";
        }
      }
      var planfor = JSON.parse(res.msg.time_content);
      if (this.planType == "pay") {
        this.$set(this.planForm, "startTime", parseInt(res.msg.start_time));
        this.$set(this.planForm, "endTime", parseInt(res.msg.end_time));
        this.$set(
            this.setPlanTime,
            "startTime",
            parseInt(res.msg.start_time) * 1000
        );
        this.$set(
            this.setPlanTime,
            "endTime",
            parseInt(res.msg.end_time) * 1000
        );
      }

      if (this.planForm.allotType == 2) {
        if (this.planType == "pay") {
          this.$forceUpdate(); //强制刷新
          this.planForm.planTime = planfor;
          this.totalAllocation();
        } else {
          this.changeTimeTab(this.planForm.allotType);
        }
      }
      if (this.creatPlanType == "sales") {
        res.msg.saleNum.forEach((item, index) => {
          this.taskPayMoney = item.pay_money
          this.taskBuyNum = item.buy_num
          this.planForm.planMessage[index] = {
            keyword: item.keyword,
            payMoney: item.pay_money,
            sku: item.sku,
            entranceType: item.entrance_type,
            taskNum: item.plan_num,
            buyNum: item.buy_num
          };
        });
        this.isHideTaoKeCard()// 是否隐藏淘客选项
      } else {
        res.msg.flowNum.forEach((item, index) => {
          this.planForm.planMessage[index] = {
            keyword: item.keyword,
            entranceType: item.entrance_type,
            taskType: {
              1: 0,
              2: 0,
              3: 0,
              4: 0,
              5: 0,
              6: 0,
              7: 0,
              8: 0
            }
          };
          Object.keys(item.flow_task_info).forEach((ite, inde) => {
            this.planForm.planMessage[index].taskType[inde + 1] =
                item.flow_task_info[ite].num;
          });
        });
      }
    },
    isBlank(val) {
      if (val == null || val == "") {
        return true;
      }
    },
    //=========================销量=========================
    getCurSelectQrcode(index) {
      this.curQrcodeIndex = index;
    },
    qrcodeSuccess(res, file) {
      for (var i in this.planForm.planMessage) {
        if (i == this.curQrcodeIndex) {
          this.planForm.planMessage[i].keyword = res.msg;
        }
      }
      this.$forceUpdate();
      this.$message.success("上传成功");
    },
    qrcodeBeforeAvatarUpload(file) {
      const isLt2M = file.size / 1024 / 1024 < 10;
      if (!isLt2M) {
        this.$message.error("上传头像图片大小不能超过 10MB!");
      }
      return isLt2M;
    },
    getCheckContentText() {
      this.planForm.checkContent = this.planForm.checkContent.replace(
          /[^\a-\z\A-\Z0-9\u4E00-\u9FA5\！\!\:\;\：\；\，\,\.\。\【】\{}\ \()\-\（）]/g,
          ""
      );
      if (
          this.planForm.checkContent.length >= 1 &&
          this.planForm.checkContent.length < 5
      ) {
        this.checkContent = "";
        this.$message.error("商品详情页文本字数要为5个");
        return;
      }
      if (this.planForm.checkContent.indexOf(" ") >= 0) {
        this.checkContent = "";
        this.$message.error("商品详情页文本不能包含空格");
        return;
      }
      if (this.planForm.checkContent.length == 5) {
        var leftStr = this.planForm.checkContent.substring(0, 2);
        var rightStr = this.planForm.checkContent.substring(3, 5);
        this.checkContent = leftStr + "( )" + rightStr;
      }
    }
    //=========================流量===========================
  }
};
</script>

<style lang="less">
#create-plan {
  .plan-card {
    background: #ffffff;
    margin-bottom: 16px;
    box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.1);
    padding-bottom: 16px;
    border-radius: 5px;
    border-top: 3px solid @themeColor;
    .plan-card-header {
      background: #ecf5ff;
      padding: 10px;
      display: flex;
      align-items: center;
      margin-bottom: 16px;
      .title {
        line-height: 20px;
        border-left: 3px solid #666666;
        padding-left: 10px;
        font-size: 16px;
        font-weight: 700;
        color: #333333;
        width: 150px;
      }
      .tips {
        font-size: 14px;
        color: red;
      }
    }
    .plan-card-content {
      padding: 10px 20px;
      .zqd-tips {
        color: red;
        font-size: 14px;
        margin-bottom: 10px;
      }
      &.other-style {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
      .goods-form {
        .el-form-item {
          margin-bottom: 17px;
        }
        .form-input {
          width: 300px;
        }
        .form-btn {
          display: inline-block;
          margin-left: 20px;
          border: 1px solid @themeColor;
          border-radius: 4px;
          font-size: 12px;
          color: @themeColor;
          text-align: center;
          padding: 8px 20px;
        }
        .form-btn-tips {
          display: inline-block;
          margin-left: 20px;
          border: 1px solid #909090;
          border-radius: 4px;
          font-size: 12px;
          color: #909090;
          text-align: center;
          line-height: 28px;
          padding: 0 20px;
        }
        .other-info {
          display: flex;
          align-items: center;
          justify-content: space-between;
          .other-info-input {
            width: 100px;
          }
        }
      }
      .goods-img-box {
        margin-right: 50px;
        .goods-img {
          text-align: center;
          color: #606266;
          img {
            width: 260px;
            height: 260px;
            border: 1px dashed #666666;
          }
          .upload-icon {
            width: 260px;
            height: 260px;
            border: 1px dashed #666666;
            text-align: center;
            line-height: 260px;
            color: #a5a5a5;
            font-size: 30px;
          }
        }
      }
      // 任务信息样式
      .task-card {
        display: flex;
        align-items: center;
        justify-content: space-between;
        border: 1px dashed #a5a5a5;
        padding: 36px 20px 20px 20px;
        .task-card-left {
          .form-box {
            margin-bottom: 16px;

            .title {
              font-size: 14px;
              color: @fontSubtitleColor;
              width: 80px;
              text-align: right;
              display: inline-block;
              .star-text {
                color: red;
              }
            }
            .form-input {
              width: 200px;
              vertical-align: middle;
              margin-left: 5px;
            }
            img {
              width: 200px;
              height: 200px;
              border: 1px dashed #a5a5a5;
              vertical-align: text-top;
            }
            .qrcode-img-box {
              display: inline-block;
              margin-left: 5px;
              img {
                width: 200px;
                height: 200px;
                border: 1px dashed #a5a5a5;
              }
              .upload-icon {
                width: 200px;
                height: 200px;
                border: 1px dashed #a5a5a5;
                text-align: center;
                line-height: 200px;
                color: #a5a5a5;
                font-size: 20px;
              }
            }
          }
        }
        .task-card-center {
          &.flow-center {
            display: flex;
            align-items: center;
          }
          .center-cell {
            display: flex;
            align-items: center;
          }
          .form-box {
            margin-bottom: 16px;
            margin-right: 20px;
            color: @fontSubtitleColor;
            font-size: 14px;
            .title {
              font-size: 14px;
              color: @fontSubtitleColor;
              width: 80px;
              text-align: right;
              display: inline-block;
              .star-text {
                color: red;
              }
            }
            .form-input {
              width: 150px;
              vertical-align: middle;
              margin: 0 5px;
            }
          }
          .center-row {
            .flow-form-box {
              margin-bottom: 16px;
              margin-right: 20px;
              color: @fontSubtitleColor;
              font-size: 14px;
              .title {
                font-size: 14px;
                color: @fontSubtitleColor;
                width: 160px;
                text-align: right;
                display: inline-block;
              }
              .form-input {
                width: 100px;
                vertical-align: middle;
                margin: 0 5px;
              }
            }
          }
        }
        .task-card-right {
          i {
            font-size: 20px;
            padding: 8px;
            cursor: pointer;
            display: block;
          }
          .add-task-icon {
            color: @themeColor;
          }
          .cut-task-icon {
            color: red;
          }
        }
      }
      .time-type-box {
        display: flex;
        align-items: center;
        .title {
          font-size: 14px;
          color: @fontSubtitleColor;
          width: 80px;
          text-align: right;
          display: inline-block;
        }
        .tabs-nav {
          border-radius: 5px;
          border: 1px solid #e0e0e0;
          &.disabled-click {
            background: #f5f7fa;
            .tab {
              cursor: not-allowed;
              &.active {
                background: #dce5f3;
                color: #333333;
              }
            }
          }
          .tab {
            display: inline-block;
            font-size: 13px;
            color: @fontSubtitleColor;
            padding: 5px 12px;
            cursor: pointer;
            &:nth-child(1) {
              &.active {
                border-top-left-radius: 5px;
                border-bottom-left-radius: 5px;
              }
            }
            &:nth-child(2) {
              border-left: 1px solid #a5a5a5;
              border-right: 1px solid #a5a5a5;
            }
            &:nth-child(3) {
              &.active {
                border-top-right-radius: 5px;
                border-bottom-right-radius: 5px;
              }
            }
            &.active {
              color: #ffffff;
              background: @themeColor;
            }
          }
        }
      }
      .set-time-box {
        display: flex;
        align-items: center;
        margin: 30px 0;
        .title {
          font-size: 14px;
          color: @fontSubtitleColor;
          width: 80px;
          text-align: right;
          display: inline-block;
        }
        .time-select-box {
          .check-box {
            margin-left: 30px;
            .el-checkbox__label {
              color: @fontSubtitleColor;
              font-weight: normal;
              margin-right: 10px;
            }
          }
        }
      }
      .set-number {
        position: relative;
        // display: flex;
        .title {
          font-size: 14px;
          color: @fontSubtitleColor;
          width: 80px;
          text-align: right;
          display: inline-block;
        }
        .plan-time-box {
          background: #f5f5f5;
          border-radius: 5px;
          display: inline-block;
          margin-right: 10px;
          margin-bottom: 10px;
          text-align: center;
          font-size: 14px;
          padding: 10px;
          border-radius: 5px;
          .time {
            margin-bottom: 10px;
          }
        }
        .el-tag {
          //background: @themeColor;
          //color: #fff;
          margin: 10px 0;
        }

        .count-number {
          font-size: 16px;
          color: #333333;
          text-align: right;
          margin-right: 50px;
        }
        .el-collapse {
          border: none;
          padding-bottom: 10px;
          .is-active {
            .el-tag {
              background: @themeColor;
              color: #fff;
              margin: 10px 0;
            }
          }
        }
        .set-n-row {
          padding: 0 10px 10px 10px;
        }
        //.el-collapse{
        //  border: none;
        //}
      }
      .remark-box {
        margin-top: 20px;
        border-top: 1px dashed #e0e0e0;
        padding: 25px 0;
        .remark-example-box {
          .remark-example {
            color: @themeColor;
            border: 1px solid @themeColor;
            padding: 5px 15px;
            border-radius: 5px;
            font-size: 12px;
            cursor: pointer;
            display: inline-block;
            margin-right: 10px;
            margin-bottom: 10px;
          }
        }
        .textarea-box {
          font-size: 14px;
          color: @fontSubtitleColor;
          margin-top: 32px;
          .title {
            color: red;
          }
          .el-textarea {
            vertical-align: text-top;
          }
        }
      }
      .select-area-btn {
        width: 60%;
        text-align: left;
        overflow: hidden;
      }
      .price-text {
        display: inline-block;
        color: red;
        margin-left: 16px;
        font-size: 14px;
      }
      .tips {
        font-size: 14px;
        color: red;
      }
      .title {
        font-size: 14px;
        color: @fontSubtitleColor;
      }
      .check-content-box {
        font-size: 14px;
        color: @fontSubtitleColor;
        margin-top: 16px;
        .input {
          width: 200px;
          margin: 0 16px;
        }
      }
      .radio-box {
        margin-left: 16px;
      }
      .el-radio {
        color: @fontSubtitleColor;
        font-weight: normal;
      }
      .zpd-type-data {
        margin-top: 32px;
      }
    }
  }
  .page-footer {
    text-align: center;
    .show-pay-info-btn {
      background: @themeColor;
      color: #ffffff;
      font-size: 14px;
      height: 40px;
      width: 120px;
      line-height: 40px;
      padding: 0;
      margin-top: 16px;
    }
  }
  .select-goods-modal {
    /deep/ .el-dialog {
      .el-dialog__body {
        padding: 0 20px !important;
      }
    }
    .select-goods-modal-header {
      .el-form .el-form-item {
        padding-left: 0;
        padding-right: 15px;
        display: inline-flex;
        /deep/.el-form-item__content {
          width: 150px !important;
        }
        .inquire-btn {
          height: 32px !important;
          padding: 0px 10px !important;
          background: @themeColor;
          color: #ffffff;
          i {
            font-size: 14px;
          }
        }
      }
    }
    .select-goods-modal-content {
      max-height: 300px;
      overflow-y: scroll;
      .goods-img-box {
        width: 180px;
        display: inline-block;
        margin: 8px;
        cursor: pointer;
        border: 1px solid transparent;
        box-shadow: 0px 0px 3px #666;
        padding: 5px;
        border-radius: 3px;
        .text {
          font-size: 14px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
        }
        .goods-img {
          width: 180px;
          height: 180px;
        }
      }
      .selectStyle {
        border: 1px solid red;
      }
    }
  }
  .area-dialog {
    .tips {
      color: red;
      margin: 0 10px 10px 0;
      font-size: 14px;
    }
    .area-content {
      border: 1px solid #e0e0e0;
      margin: 20px 10px 0 10px;
      /deep/ .el-checkbox__label {
        color: rgb(96, 98, 102) !important;
        font-weight: initial !important;
      }
      .province-select {
        padding: 10px 20px;
        border-bottom: 1px solid #e0e0e0;
      }
    }
    .left-box {
      display: inline-block;
      border-right: 1px solid #7d7d7d;
      margin-right: 15px;
      padding-right: 15px;
    }
    .save-btn {
      text-align: center;
      .el-button {
        border: 0px solid;
        padding: 0;
        height: 35px;
        line-height: 35px;
        width: 100px;
        background: @themeColor;
        color: #ffffff;
      }
    }
  }
  .pay-plan-dialog {
    .dialog-content {
      .card {
        display: flex;
        align-items: center;
        border: 1px solid #e0e0e0;
        border-radius: 3px;
        margin-bottom: 10px;

        .title {
          padding: 10px 16px;
          border: 1px solid #ecf5ff;
          width: 165px;
          text-align: left;
          background: #ecf5ff;
        }
        .content {
          padding: 11px 16px;
          border-left: 1px solid #e0e0e0;
          background: #ffffff;
          flex: 1;
        }
      }
    }
  }
  .no-data-img {
    text-align: center;
    margin-top: 80px;
    .tips {
      font-size: 14px;
      margin-top: 10px;
    }
  }
}
</style>
